From 39883fd1da77fcb401e92ef2f29e09a82e74ff94 Mon Sep 17 00:00:00 2001 From: li-hui-17 Date: Tue, 18 Oct 2022 11:53:34 +0800 Subject: [PATCH 1/5] new interface getRdbStoreV9 Signed-off-by: li-hui-17 --- api/@ohos.data.rdb.d.ts | 89 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 9ae430851b..a9629cb0ac 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -43,6 +43,42 @@ declare namespace rdb { function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; function getRdbStore(context: Context, config: StoreConfig, version: number): Promise; + /** + * Obtains an RDB store. + * + * You can set parameters of the RDB store as required. In general, this method is recommended + * to obtain a rdb store. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfig} config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @param {AsyncCallback} callback - the RDB store {@link RdbStoreV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed open database by invalid database name + * @throws {BusinessError} 14800011 - if failed open database by database corrupted + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function getRdbStoreV9(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; + + /** + * Obtains an RDB store. + * + * You can set parameters of the RDB store as required. In general, this method is recommended + * to obtain a rdb store. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfig} config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @returns {Promise} the RDB store {@link RdbStoreV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed open database by invalid database name + * @throws {BusinessError} 14800011 - if failed open database by database corrupted + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function getRdbStoreV9(context: Context, config: StoreConfig, version: number): Promise; + /** * Deletes the database with a specified name. * @@ -95,6 +131,59 @@ declare namespace rdb { SUBSCRIBE_TYPE_REMOTE = 0, } + /** + * Describes the {@code RdbStoreV9} type. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + enum SecurityLevel { + /** + * S0: mains the db is public. + * There is no impact even if the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S0 = 0, + + /** + * S1: mains the db is low level security + * There are some low impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S1 = 1, + + /** + * S2: mains the db is middle level security + * There are some major impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S2 = 2, + + /** + * S3: mains the db is high level security + * There are some severity impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S3 = 3, + + /** + * S4: mains the db is critical level security + * There are some critical impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S4 = 4, + } + /** * Provides methods for managing the relational database (RDB). * -- Gitee From 19cd4a78753bbb8acc4ee5e2620212b4fcdde7ee Mon Sep 17 00:00:00 2001 From: li-hui-17 Date: Tue, 18 Oct 2022 14:07:16 +0800 Subject: [PATCH 2/5] add StoreConfigV9 Signed-off-by: li-hui-17 --- api/@ohos.data.rdb.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index a9629cb0ac..b433eedc03 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -478,6 +478,42 @@ declare namespace rdb { encrypt?: boolean; } + /** + * Manages relational database configurations. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface StoreConfigV9 { + /** + * The database name. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + name: string; + + /** + * Specifies whether the database is encrypted. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + securityLevel: SecurityLevel; + + /** + * Specifies whether the database is encrypted. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + encrypt?: boolean; + } + /** * Manages relational database configurations. * -- Gitee From 58d4d229e9a0e27639db5678ebe1e2bf96c66f59 Mon Sep 17 00:00:00 2001 From: li-hui-17 Date: Wed, 19 Oct 2022 17:00:03 +0800 Subject: [PATCH 3/5] add RdbStoreV9 Signed-off-by: li-hui-17 --- api/@ohos.data.rdb.d.ts | 455 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 453 insertions(+), 2 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index b433eedc03..0e15ef27b8 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -59,7 +59,7 @@ declare namespace rdb { * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 9 */ - function getRdbStoreV9(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; + function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number, callback: AsyncCallback): void; /** * Obtains an RDB store. @@ -77,7 +77,7 @@ declare namespace rdb { * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 9 */ - function getRdbStoreV9(context: Context, config: StoreConfig, version: number): Promise; + function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number): Promise; /** * Deletes the database with a specified name. @@ -438,6 +438,457 @@ declare namespace rdb { off(event:'dataChange', type: SubscribeType, observer: Callback>): void; } + /** + * Provides methods for managing the relational database (RDB). + * + * This class provides methods for creating, querying, updating, and deleting RDBs. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface RdbStoreV9 { + /** + * Inserts a row of data into the target table. + * + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the row ID if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + insert(table: string, values: ValuesBucket, callback: AsyncCallback): void; + + /** + * Inserts a row of data into the target table. + * + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the row ID if the operation is successful. return -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + insert(table: string, values: ValuesBucket): Promise; + + /** + * Inserts a batch of data into the target table. + * + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the number of values that were inserted if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + batchInsert(table: string, values: Array, callback: AsyncCallback): void; + + /** + * Inserts a batch of data into the target table. + * + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the number of values that were inserted if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + batchInsert(table: string, values: Array): Promise; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. + * + * @param {ValuesBucket} values - Indicates 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 {RdbPredicatesV9} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicatesV9}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + update(values: ValuesBucket, predicates: RdbPredicatesV9, callback: AsyncCallback): void; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. + * + * @param {ValuesBucket} values - Indicates 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 {RdbPredicatesV9} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicatesV9}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + update(values: ValuesBucket, predicates: RdbPredicatesV9): Promise; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. + * + * @param {string} table - Indicates the target table. + * @param {ValuesBucket} 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 {DataSharePredicates} predicates - Indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. + * + * @param {string} table - Indicates the target table. + * @param {ValuesBucket} 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 {DataSharePredicates} predicates - Indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. + * + * @param {RdbPredicatesV9} predicates - the specified delete condition by the instance object of {@link RdbPredicatesV9}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + delete(predicates: RdbPredicatesV9, callback: AsyncCallback): void; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. + * + * @param {RdbPredicatesV9} predicates - the specified delete condition by the instance object of {@link RdbPredicatesV9}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + delete(predicates: RdbPredicatesV9): Promise; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. + * + * @param {string} table - Indicates the target table. + * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. + * + * @param {string} table - Indicates the target table. + * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Queries data in the database based on specified conditions. + * + * @param {RdbPredicatesV9} predicates - the specified query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(predicates: RdbPredicatesV9, columns: Array, callback: AsyncCallback): void; + + /** + * Queries data in the database based on specified conditions. + * + * @param {RdbPredicatesV9} predicates - the specified query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(predicates: RdbPredicatesV9, columns?: Array): Promise; + + /** + * Queries data in the database based on specified conditions. + * + * @param {string} table - Indicates the target table. + * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; + + /** + * Queries data in the database based on specified conditions. + * + * @param {string} table - Indicates the target table. + * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array): Promise; + + /** + * Queries remote data in the database based on specified conditions before Synchronizing Data. + * + * @param {string} device - Indicates specified remote device. + * @param {string} table - Indicates the target table. + * @param {RdbPredicatesV9} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + remoteQuery(device: string, table: string, predicates: RdbPredicatesV9, columns: Array, callback: AsyncCallback): void; + + /** + * Queries remote data in the database based on specified conditions before Synchronizing Data. + * + * @param {string} device - Indicates specified remote device. + * @param {string} table - Indicates the target table. + * @param {RdbPredicatesV9} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + remoteQuery(device: string, table: string, predicates: RdbPredicatesV9, columns: Array): Promise; + + /** + * Queries data in the database based on SQL statement. + * + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. + * + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + querySql(sql: string, bindArgs?: Array): Promise; + + /** + * Executes an SQL statement that contains specified parameters but returns no value. + * + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @param {AsyncCallback} callback - the callback of executeSql. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + executeSql(sql: string, bindArgs: Array, callback: AsyncCallback): void; + + /** + * Executes an SQL statement that contains specified parameters but returns no value. + * + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + executeSql(sql: string, bindArgs?: Array): Promise; + + /** + * beginTransaction before excute your sql. + * + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + beginTransaction():void; + + /** + * commit the the sql you have excuted. + * + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + commit():void; + + /** + * roll back the sql you have already excuted. + * + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + rollBack():void; + + /** + * Backs up a database in a specified name. + * + * @param {string} destName - Indicates the name that saves the database backup. + * @param {AsyncCallback} callback - the callback of backup. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + backup(destName:string, callback: AsyncCallback):void; + + /** + * Backs up a database in a specified name. + * + * @param {string} destName - Indicates the name that saves the database backup. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + backup(destName:string): Promise; + + /** + * Restores a database from a specified database file. + * + * @param {string} srcName - Indicates the name that saves the database file. + * @param {AsyncCallback} callback - the callback of restore. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + restore(srcName:string, callback: AsyncCallback):void; + + /** + * Restores a database from a specified database file. + * + * @param {string} srcName - Indicates the name that saves the database file. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + restore(srcName:string): Promise; + + /** + * Set table to be distributed table. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {Array} tables - Indicates the tables name you want to set. + * @param {AsyncCallback} callback - the callback of setDistributedTables. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + setDistributedTables(tables: Array, callback: AsyncCallback): void; + + /** + * Set table to be distributed table. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {Array} tables - Indicates the tables name you want to set. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + setDistributedTables(tables: Array): Promise; + + /** + * Obtain distributed table name of specified remote device according to local table name. + * When query remote device database, distributed table name is needed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback} callback - {string}: the distributed table name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void; + + /** + * Obtain distributed table name of specified remote device according to local table name. + * When query remote device database, distributed table name is needed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @returns {Promise} {string}: the distributed table name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + obtainDistributedTableName(device: string, table: string): Promise; + + /** + * Sync data between devices. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback>} callback - {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + sync(mode: SyncMode, predicates: RdbPredicatesV9, callback: AsyncCallback>): void; + + /** + * Sync data between devices. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @returns {Promise>} {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + sync(mode: SyncMode, predicates: RdbPredicatesV9): Promise>; + + /** + * Registers an observer for the database. When data in the distributed database changes, + * the callback will be invoked. + * + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the observer of data change events in the distributed database. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; + + /** + * Remove specified observer of specified type from the database. + * + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the data change observer already registered. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + off(event:'dataChange', type: SubscribeType, observer: Callback>): void; + } + /** * Indicates possible value types * -- Gitee From 0cc8a6e25e5f5e50ab818fe500c035baf2fedd71 Mon Sep 17 00:00:00 2001 From: lihuihui Date: Fri, 21 Oct 2022 18:00:23 +0800 Subject: [PATCH 4/5] modify s1-s4 Signed-off-by: lihuihui --- api/@ohos.data.rdb.d.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 0e15ef27b8..f9e2fd141d 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -138,15 +138,6 @@ declare namespace rdb { * @since 9 */ enum SecurityLevel { - /** - * S0: mains the db is public. - * There is no impact even if the data is leaked. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - S0 = 0, - /** * S1: mains the db is low level security * There are some low impact, when the data is leaked. -- Gitee From 1d9abf8f874bc85cfa1f802bc78e5204b18ccebe Mon Sep 17 00:00:00 2001 From: lihuihui Date: Fri, 21 Oct 2022 18:41:02 +0800 Subject: [PATCH 5/5] modify suggest Signed-off-by: lihuihui --- 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 f9e2fd141d..38dfeb4914 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -332,7 +332,7 @@ declare namespace rdb { beginTransaction():void; /** - * commit the the sql you have excuted. + * commit the the sql you have executed. * * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core @@ -340,7 +340,7 @@ declare namespace rdb { commit():void; /** - * roll back the sql you have already excuted + * roll back the sql you have already executed * * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core @@ -710,7 +710,7 @@ declare namespace rdb { executeSql(sql: string, bindArgs?: Array): Promise; /** - * beginTransaction before excute your sql. + * BeginTransaction before excute your sql. * * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core @@ -719,7 +719,7 @@ declare namespace rdb { beginTransaction():void; /** - * commit the the sql you have excuted. + * Commit the the sql you have executed. * * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core @@ -728,7 +728,7 @@ declare namespace rdb { commit():void; /** - * roll back the sql you have already excuted. + * Roll back the sql you have already executed. * * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core -- Gitee