From bb918b22cbbf2852a93a53f26054636bdc40abb1 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Mon, 11 Apr 2022 16:13:17 +0800 Subject: [PATCH 1/8] add two interfaces: backup,restore Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index f49a6db5ce..fb0d497051 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -275,6 +275,31 @@ declare namespace rdb { * @param observer Indicates the data change observer already registered . */ off(event:'dataChange', type: SubscribeType, observer: Callback>): void; + + /** + * Back up the database to the specified path. + * + * @note N/A + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param databasePath Indicates the backup path of the database. + * @return Returns 0 if the back up operation is successfull. + */ + backup(databasePath:string, callback: AsyncCallback):void; + backup(databasePath:string): Promise; + + /** + * Restore the database backup file to the specified path. + * + * @note N/A + * @since 8 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param newPath Indicates the path to which the database backup files are to be restored. + * @param backupPath Indicates the backup path of the database. + * @return Returns 0 if the back up operation is successfull. + */ + ChangeDbFileForRestore(newPath:string, backupPath:string, callback: AsyncCallback):void; + ChangeDbFileForRestore(newPath:string, backupPath:string): Promise; } /** -- Gitee From f0cf82f61b20989029ed7ae9e9a4914a0657f287 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Mon, 11 Apr 2022 16:30:51 +0800 Subject: [PATCH 2/8] update Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index fb0d497051..aafe95b267 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -298,8 +298,8 @@ declare namespace rdb { * @param backupPath Indicates the backup path of the database. * @return Returns 0 if the back up operation is successfull. */ - ChangeDbFileForRestore(newPath:string, backupPath:string, callback: AsyncCallback):void; - ChangeDbFileForRestore(newPath:string, backupPath:string): Promise; + restore(newPath:string, backupPath:string, callback: AsyncCallback):void; + restore(newPath:string, backupPath:string): Promise; } /** -- Gitee From 7ce80fd49cb8ed5949fd01e6f95adf3bf1dc16a8 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Tue, 12 Apr 2022 14:03:05 +0800 Subject: [PATCH 3/8] update Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index aafe95b267..38d38926ad 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -296,7 +296,7 @@ declare namespace rdb { * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param newPath Indicates the path to which the database backup files are to be restored. * @param backupPath Indicates the backup path of the database. - * @return Returns 0 if the back up operation is successfull. + * @return Returns 0 if the restore operation is successfull. */ restore(newPath:string, backupPath:string, callback: AsyncCallback):void; restore(newPath:string, backupPath:string): Promise; -- Gitee From ab6033e06906d09cd8280469fc0569aa6f3f6c82 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Wed, 13 Apr 2022 09:39:24 +0800 Subject: [PATCH 4/8] update Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 38d38926ad..1bec942d6b 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -280,7 +280,7 @@ declare namespace rdb { * Back up the database to the specified path. * * @note N/A - * @since 8 + * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param databasePath Indicates the backup path of the database. * @return Returns 0 if the back up operation is successfull. @@ -292,7 +292,7 @@ declare namespace rdb { * Restore the database backup file to the specified path. * * @note N/A - * @since 8 + * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param newPath Indicates the path to which the database backup files are to be restored. * @param backupPath Indicates the backup path of the database. -- Gitee From f7521fa38b6878b0ee0fd1581047fefc2ca37bee Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 14 Apr 2022 15:15:55 +0800 Subject: [PATCH 5/8] update Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 1bec942d6b..2e2703195d 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -283,10 +283,9 @@ declare namespace rdb { * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param databasePath Indicates the backup path of the database. - * @return Returns 0 if the back up operation is successfull. */ - backup(databasePath:string, callback: AsyncCallback):void; - backup(databasePath:string): Promise; + backup(databasePath:string, callback: AsyncCallback):void; + backup(databasePath:string): Promise; /** * Restore the database backup file to the specified path. @@ -296,10 +295,9 @@ declare namespace rdb { * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param newPath Indicates the path to which the database backup files are to be restored. * @param backupPath Indicates the backup path of the database. - * @return Returns 0 if the restore operation is successfull. */ - restore(newPath:string, backupPath:string, callback: AsyncCallback):void; - restore(newPath:string, backupPath:string): Promise; + restore(newPath:string, backupPath:string, callback: AsyncCallback):void; + restore(newPath:string, backupPath:string): Promise; } /** -- Gitee From 0de675fe92f08bb3e9e4fba152ecf3522b3baf6c Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 5 May 2022 15:08:49 +0800 Subject: [PATCH 6/8] update file Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 2e2703195d..565969342c 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -277,24 +277,24 @@ declare namespace rdb { off(event:'dataChange', type: SubscribeType, observer: Callback>): void; /** - * Back up the database to the specified path. + * Backup the database. * * @note N/A * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param databasePath Indicates the backup path of the database. + * @param databasePath Indicates the backup name of the database. */ backup(databasePath:string, callback: AsyncCallback):void; backup(databasePath:string): Promise; /** - * Restore the database backup file to the specified path. + * Restore the database. * * @note N/A * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param newPath Indicates the path to which the database backup files are to be restored. - * @param backupPath Indicates the backup path of the database. + * @param newPath Indicates the restore name when the database restored. + * @param backupPath Indicates the backup name of the database. */ restore(newPath:string, backupPath:string, callback: AsyncCallback):void; restore(newPath:string, backupPath:string): Promise; -- Gitee From 4b517e1dd7a8a38e1c3e8d47b36c4db2b2bd4cde Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 12 May 2022 10:13:49 +0800 Subject: [PATCH 7/8] add dataShare insert/update/delete/query Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 98 +++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 565969342c..f79cb9fe6d 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -16,7 +16,9 @@ import {AsyncCallback, Callback} from './basic'; import { ResultSet } from './data/rdb/resultSet'; import Context from "./application/Context"; - +import DataSharePredicates from './@ohos.data.DataSharePredicates'; +import DataShareResultSet from "./@ohos.data.DataShareResultSet"; +import { DataShareValuesBucket } from "./@ohos.data.DataShareValuesBucket"; /** * Provides methods for rdbStore create and delete. * @@ -123,6 +125,19 @@ declare namespace rdb { insert(name: string, values: ValuesBucket, callback: AsyncCallback): void; insert(name: string, values: ValuesBucket): Promise; + /** + * Inserts a row of data into the target table. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target table. + * @param values Indicates the row of data to be inserted into the table. + * @return Returns the row ID if the operation is successful; returns -1 otherwise. + */ + insert(name: string, values: DataShareValuesBucket, callback: AsyncCallback): void; + insert(name: string, values: DataShareValuesBucket): Promise; + /** * Updates data in the database based on a a specified instance object of rdbPredicates. * @@ -130,11 +145,25 @@ declare namespace rdb { * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table. - * @param rdbPredicates Indicates the specified update condition by the instance object of RdbPredicates. + * @param predicates Indicates the specified update condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback): void; + update(values: ValuesBucket, predicates: RdbPredicates): Promise; + + /** + * Updates data in the database based on a a specified instance object of rdbPredicates. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target table. + * @param values Indicates the row of data to be updated in the database.The key-value pairs are associated with column names of the database table. + * @param predicates Indicates the specified update condition by the instance object of RdbPredicates. * @return Returns the number of affected rows. */ - update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback): void; - update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise; + update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback): void; + update(name: string, values: DataShareValuesBucket, predicates: DataSharePredicates): Promise; /** * Deletes data from the database based on a specified instance object of rdbPredicates. @@ -142,11 +171,24 @@ declare namespace rdb { * @note N/A * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param rdbPredicates Indicates the specified delete condition by the instance object of RdbPredicates. + * @param predicates Indicates the specified delete condition by the instance object of RdbPredicates. + * @return Returns the number of affected rows. + */ + delete(predicates: RdbPredicates, callback: AsyncCallback): void; + delete(predicates: RdbPredicates): Promise; + + /** + * Deletes data from the database based on a specified instance object of rdbPredicates. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param name Indicates the target table. + * @param predicates Indicates the specified delete condition by the instance object of RdbPredicates. * @return Returns the number of affected rows. */ - delete(rdbPredicates: RdbPredicates, callback: AsyncCallback): void; - delete(rdbPredicates: RdbPredicates): Promise; + delete(name: string, predicates: DataSharePredicates, callback: AsyncCallback): void; + delete(name: string, predicates: DataSharePredicates): Promise; /** * Queries data in the database based on specified conditions. @@ -154,12 +196,25 @@ declare namespace rdb { * @note N/A * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param rdbPredicates Indicates the specified query condition by the instance object of RdbPredicates. + * @param predicates Indicates the specified query condition by the instance object of RdbPredicates. * @param columns Indicates the columns to query. If the value is null, the query applies to all columns. * @return Returns a ResultSet object if the operation is successful; */ - query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; - query(rdbPredicates: RdbPredicates, columns?: Array): Promise; + query(predicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; + query(predicates: RdbPredicates, columns?: Array): Promise; + + /** + * Queries data in the database based on specified conditions. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @param predicates Indicates the specified query condition by the instance object of RdbPredicates. + * @param columns Indicates the columns to query. If the value is null, the query applies to all columns. + * @return Returns a DataShareResultSet object if the operation is successful; + */ + query(name: string, predicates: DataSharePredicates, columns: Array, callback: AsyncCallback): void; + query(name: string, predicates: DataSharePredicates, columns?: Array): Promise; /** * Queries data in the database based on SQL statement. @@ -275,29 +330,6 @@ declare namespace rdb { * @param observer Indicates the data change observer already registered . */ off(event:'dataChange', type: SubscribeType, observer: Callback>): void; - - /** - * Backup the database. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param databasePath Indicates the backup name of the database. - */ - backup(databasePath:string, callback: AsyncCallback):void; - backup(databasePath:string): Promise; - - /** - * Restore the database. - * - * @note N/A - * @since 9 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param newPath Indicates the restore name when the database restored. - * @param backupPath Indicates the backup name of the database. - */ - restore(newPath:string, backupPath:string, callback: AsyncCallback):void; - restore(newPath:string, backupPath:string): Promise; } /** -- Gitee From 5fff256d88021049618f07f9c41e299e9183ecf9 Mon Sep 17 00:00:00 2001 From: wuyongning Date: Thu, 12 May 2022 10:17:58 +0800 Subject: [PATCH 8/8] update Signed-off-by: wuyongning --- api/@ohos.data.rdb.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index f79cb9fe6d..81786c4345 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -17,7 +17,6 @@ import {AsyncCallback, Callback} from './basic'; import { ResultSet } from './data/rdb/resultSet'; import Context from "./application/Context"; import DataSharePredicates from './@ohos.data.DataSharePredicates'; -import DataShareResultSet from "./@ohos.data.DataShareResultSet"; import { DataShareValuesBucket } from "./@ohos.data.DataShareValuesBucket"; /** * Provides methods for rdbStore create and delete. -- Gitee