From 08f28d68af7ab1f5ae4e20198fcf170ed9c646d2 Mon Sep 17 00:00:00 2001 From: PaDaBoo Date: Fri, 6 Jan 2023 12:54:49 +0800 Subject: [PATCH] add namespace relationalStore to replace rdb V9 api Signed-off-by: PaDaBoo --- api/@ohos.data.rdb.d.ts | 1600 ++++++--------------------- api/@ohos.data.relationalStore.d.ts | 1332 ++++++++++++++++++++++ api/data/rdb/resultSet.d.ts | 310 +----- 3 files changed, 1674 insertions(+), 1568 deletions(-) create mode 100644 api/@ohos.data.relationalStore.d.ts diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index cd5fc7cbc0..7d21733e51 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -14,15 +14,16 @@ */ import{ AsyncCallback, Callback } from './basic'; -import{ ResultSet as _ResultSet, ResultSetV9 as _ResultSetV9 } from './data/rdb/resultSet'; +import{ ResultSet as _ResultSet } from './data/rdb/resultSet'; import Context from "./application/BaseContext"; -import dataSharePredicates from './@ohos.data.dataSharePredicates'; /** * Provides methods for rdbStore create and delete. * * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore */ declare namespace rdb { @@ -39,7 +40,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.getRdbStoreV9 + * @useinstead ohos.data.relationalStore.getRdbStore */ function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; @@ -56,46 +57,10 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.getRdbStoreV9 + * @useinstead ohos.data.relationalStore.getRdbStore */ 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 {StoreConfigV9} config - Indicates the {@link StoreConfigV9} 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: StoreConfigV9, 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 {StoreConfigV9} config - Indicates the {@link StoreConfigV9} 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: StoreConfigV9, version: number): Promise; - /** * Deletes the database with a specified name. * @@ -105,7 +70,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.deleteRdbStoreV9 + * @useinstead ohos.data.relationalStore.deleteRdbStore */ function deleteRdbStore(context: Context, name: string, callback: AsyncCallback): void; /** @@ -117,56 +82,36 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.deleteRdbStoreV9 + * @useinstead ohos.data.relationalStore.deleteRdbStore */ function deleteRdbStore(context: Context, name: string): Promise; - /** - * Deletes the database with a specified name. - * - * @param {Context} context - Indicates the context of application or capability. - * @param {string} name - Indicates the database name. - * @param {AsyncCallback} callback - the callback of deleteRdbStore. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @throws {BusinessError} 14800010 - if failed delete database by invalid database name - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - function deleteRdbStoreV9(context: Context, name: string, callback: AsyncCallback): void; - - /** - * Deletes the database with a specified name. - * - * @param {Context} context - Indicates the context of application or capability. - * @param {string} name - Indicates the database name. - * @returns {Promise} the promise returned by the function. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @throws {BusinessError} 14800010 - if failed delete database by invalid database name - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - function deleteRdbStoreV9(context: Context, name: string): Promise; - /** * Indicates the database synchronization mode. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.SyncMode */ enum SyncMode { /** * Indicates the data is pushed to remote device from local device. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.SyncMode.SYNC_MODE_PUSH */ SYNC_MODE_PUSH = 0, /** * Indicates the data is pulled from remote device to local device. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.SyncMode.SYNC_MODE_PULL */ SYNC_MODE_PULL = 1, } @@ -174,63 +119,23 @@ declare namespace rdb /** * Describes the subscription type. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.SubscribeType * @permission ohos.permission.DISTRIBUTED_DATASYNC */ enum SubscribeType { /** * Subscription to remote data changes - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE */ SUBSCRIBE_TYPE_REMOTE = 0, } - /** - * Describes the {@code RdbStoreV9} type. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - enum SecurityLevel { - /** - * 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). * @@ -239,7 +144,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9 + * @useinstead ohos.data.relationalStore.RdbStore */ interface RdbStore { /** @@ -251,7 +156,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.insert + * @useinstead ohos.data.relationalStore.RdbStore.insert */ insert(table: string, values: ValuesBucket, callback: AsyncCallback): void; @@ -264,7 +169,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.insert + * @useinstead ohos.data.relationalStore.RdbStore.insert */ insert(table: string, values: ValuesBucket): Promise; @@ -277,7 +182,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.batchInsert + * @useinstead ohos.data.relationalStore.RdbStore.batchInsert */ batchInsert(table: string, values: Array, callback: AsyncCallback): void; @@ -290,7 +195,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.batchInsert + * @useinstead ohos.data.relationalStore.RdbStore.batchInsert */ batchInsert(table: string, values: Array): Promise; @@ -303,7 +208,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.update + * @useinstead ohos.data.relationalStore.RdbStore.update */ update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback): void; @@ -316,7 +221,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.update + * @useinstead ohos.data.relationalStore.RdbStore.update */ update(values: ValuesBucket, predicates: RdbPredicates): Promise; @@ -328,7 +233,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.delete + * @useinstead ohos.data.relationalStore.RdbStore.delete */ delete(predicates: RdbPredicates, callback: AsyncCallback): void; @@ -340,7 +245,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.delete + * @useinstead ohos.data.relationalStore.RdbStore.delete */ delete(predicates: RdbPredicates): Promise; @@ -353,7 +258,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.query + * @useinstead ohos.data.relationalStore.RdbStore.query */ query(predicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; @@ -366,7 +271,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.query + * @useinstead ohos.data.relationalStore.RdbStore.query */ query(predicates: RdbPredicates, columns ?: Array): Promise; @@ -379,7 +284,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.querySql + * @useinstead ohos.data.relationalStore.RdbStore.querySql */ querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; @@ -392,7 +297,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.querySql + * @useinstead ohos.data.relationalStore.RdbStore.querySql */ querySql(sql: string, bindArgs ?: Array): Promise; @@ -405,7 +310,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.executeSql + * @useinstead ohos.data.relationalStore.RdbStore.executeSql */ executeSql(sql: string, bindArgs: Array, callback: AsyncCallback): void; @@ -418,7 +323,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.executeSql + * @useinstead ohos.data.relationalStore.RdbStore.executeSql */ executeSql(sql: string, bindArgs ?: Array): Promise; @@ -428,7 +333,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.beginTransaction + * @useinstead ohos.data.relationalStore.RdbStore.beginTransaction */ beginTransaction(): void; @@ -438,7 +343,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.commit + * @useinstead ohos.data.relationalStore.RdbStore.commit */ commit(): void; @@ -448,7 +353,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.rollBack + * @useinstead ohos.data.relationalStore.RdbStore.rollBack */ rollBack(): void; @@ -461,7 +366,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.setDistributedTables + * @useinstead ohos.data.relationalStore.RdbStore.setDistributedTables */ setDistributedTables(tables: Array, callback: AsyncCallback): void; @@ -474,7 +379,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.setDistributedTables + * @useinstead ohos.data.relationalStore.RdbStore.setDistributedTables */ setDistributedTables(tables: Array): Promise; @@ -488,7 +393,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.obtainDistributedTableName + * @useinstead ohos.data.relationalStore.RdbStore.obtainDistributedTableName */ obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void; @@ -502,7 +407,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.obtainDistributedTableName + * @useinstead ohos.data.relationalStore.RdbStore.obtainDistributedTableName */ obtainDistributedTableName(device: string, table: string): Promise; @@ -515,7 +420,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.sync + * @useinstead ohos.data.relationalStore.RdbStore.sync */ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void; @@ -528,7 +433,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.sync + * @useinstead ohos.data.relationalStore.RdbStore.sync */ sync(mode: SyncMode, predicates: RdbPredicates): Promise>; @@ -542,7 +447,7 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.on + * @useinstead ohos.data.relationalStore.RdbStore.on */ on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; @@ -555,1338 +460,469 @@ declare namespace rdb * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 8 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbStoreV9.off + * @useinstead ohos.data.relationalStore.RdbStore.off */ off(event: 'dataChange', type: SubscribeType, observer: Callback>): void; } /** - * Provides methods for managing the relational database (RDB). + * Indicates possible value types * - * This class provides methods for creating, querying, updating, and deleting RDBs. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.ValueType + */ + type ValueType = number | string | boolean; + + /** + * Values in buckets are stored in key-value pairs * * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.ValuesBucket */ - 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; + type ValuesBucket = { [key:string]: ValueType | Uint8Array | null; +} - /** - * 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; +/** + * Manages relational database configurations. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.StoreConfig + */ +interface StoreConfig { + name: string; +} - /** - * 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; +/** + * Manages relational database configurations. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates + */ +class RdbPredicates { + /** + * A parameterized constructor used to create an RdbPredicates instance. + * + * @param {string} name - Indicates the table name of the database. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.constructor + */ + constructor(name: string) - /** - * 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; + /** + * Sync data between devices. + * When query database, this function should not be called. + * + * @param {Array} devices - Indicates specified remote devices. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.inDevices + */ + inDevices(devices: Array): RdbPredicates; - /** - * 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; + /** + * Specify all remote devices which connect to local device when syncing distributed database. + * When query database, this function should not be called. + * + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.inAllDevices + */ + inAllDevices(): RdbPredicates; - /** - * 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; + /** + * Configure the RdbPredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * This method is similar to = of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.equalTo + */ + equalTo(field: string, value: ValueType): RdbPredicates; - /** - * 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 - * @systemapi - * @since 9 - */ - update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + /** + * Configure the RdbPredicates to match the field whose data type is ValueType and value is not equal to + * a specified value. + * This method is similar to != of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.notEqualTo + */ + notEqualTo(field: string, value: ValueType): RdbPredicates; - /** - * 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 - * @systemapi - * @since 9 - */ - update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; + /** + * Adds a left parenthesis to the RdbPredicates. + * This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * + * @returns {RdbPredicates} - the {@link RdbPredicates} with the left parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.beginWrap + */ + beginWrap(): RdbPredicates; - /** - * 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; + /** + * Adds a right parenthesis to the RdbPredicates. + * This method is similar to ) of the SQL statement and needs to be used together + * + * with beginWrap(). + * @returns {RdbPredicates} - the {@link RdbPredicates} with the right parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.endWrap + */ + endWrap(): RdbPredicates; - /** - * 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 - * @systemapi - * @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 - * @systemapi - * @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 - * @systemapi - * @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 - * @systemapi - * @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 execute 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 executed. - * - * @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 executed. - * - * @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 - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - */ - type ValueType = number | string | boolean; - - /** - * Values in buckets are stored in key-value pairs - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - */ - type ValuesBucket = { [key:string]: ValueType | Uint8Array | null; -} - -/** - * Manages relational database configurations. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.StoreConfigV9 - */ -interface StoreConfig { - name: string; -} - -/** - * Manages relational database configurations. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ -interface StoreConfigV9 { - /** - * The database name. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - name: string; - - /** - * Specifies whether the database is encrypted. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - securityLevel: SecurityLevel; - - /** - * Specifies whether the database is encrypted. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - encrypt ?: boolean; -} - -/** - * Manages relational database configurations. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9 - */ -class RdbPredicates { - /** - * A parameterized constructor used to create an RdbPredicates instance. - * - * @param {string} name - Indicates the table name of the database. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.constructor - */ - constructor(name: string) - - /** - * Sync data between devices. - * When query database, this function should not be called. - * - * @param {Array} devices - Indicates specified remote devices. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 8 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.inDevices - */ - inDevices(devices: Array): RdbPredicates; - - /** - * Specify all remote devices which connect to local device when syncing distributed database. - * When query database, this function should not be called. - * - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 8 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.inAllDevices - */ - inAllDevices(): RdbPredicates; - - /** - * Configure the RdbPredicatesV9 to match the field whose data type is ValueType and value is equal - * to a specified value. - * This method is similar to = of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.equalTo - */ - equalTo(field: string, value: ValueType): RdbPredicates; - - /** - * Configure the RdbPredicatesV9 to match the field whose data type is ValueType and value is not equal to - * a specified value. - * This method is similar to != of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.notEqualTo - */ - notEqualTo(field: string, value: ValueType): RdbPredicates; - - /** - * Adds a left parenthesis to the RdbPredicates. - * This method is similar to ( of the SQL statement and needs to be used together with endWrap(). - * - * @returns {RdbPredicates} - the {@link RdbPredicates} with the left parenthesis. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.beginWrap - */ - beginWrap(): RdbPredicates; - - /** - * Adds a right parenthesis to the RdbPredicates. - * This method is similar to ) of the SQL statement and needs to be used together - * - * with beginWrap(). - * @returns {RdbPredicates} - the {@link RdbPredicates} with the right parenthesis. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.endWrap - */ - endWrap(): RdbPredicates; - - /** - * Adds an or condition to the RdbPredicates. - * This method is similar to or of the SQL statement. - * - * @returns Returns the {@link RdbPredicates} with the or condition. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.or - */ - or(): RdbPredicates; - - /** - * Adds an and condition to the RdbPredicates. - * This method is similar to or of the SQL statement. - * - * @returns Returns the {@link RdbPredicates} with the or condition. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.and - */ - and(): RdbPredicates; - - /** - * Configure the RdbPredicates to match the field whose data type is string and value - * contains a specified value. - * This method is similar to contains of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.contains - */ - contains(field: string, value: string): RdbPredicates; - - /** - * Configure the RdbPredicates to match the field whose data type is string and value starts - * with a specified string. - * This method is similar to value% of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.beginsWith - */ - beginsWith(field: string, value: string): RdbPredicates; - - /** - * Configure the RdbPredicates to match the field whose data type is string and value - * ends with a specified string. - * This method is similar to %value of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.endsWith - */ - endsWith(field: string, value: string): RdbPredicates; - - /** - * Configure the RdbPredicates to match the fields whose value is null. - * This method is similar to is null of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.isNull - */ - isNull(field: string): RdbPredicates; - - /** - * Configure the RdbPredicates to match the specified fields whose value is not null. - * This method is similar to is not null of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @returns {RdbPredicates} - the {@link RdbPredicates} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.isNotNull - */ - isNotNull(field: string): RdbPredicates; - - /** - * Configure the RdbPredicates to match the fields whose data type is string and value is - * similar to a specified string. - * This method is similar to like of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the {@link RdbPredicates} that match the specified field. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.like - */ - like(field: string, value: string): RdbPredicates; - - /** - * Configure RdbPredicates to match the specified field whose data type is string and the value contains - * a wildcard. - * Different from like, the input parameters of this method are case-sensitive. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.glob - */ - glob(field: string, value: string): RdbPredicates; - - /** - * Configure RdbPredicates to match the specified field whose data type is string and the value contains - * a wildcard. - * - * @param {string} field - Indicates the column name. - * @param {ValueType} low - Indicates the minimum value. - * @param {ValueType} high - Indicates the maximum value. - * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.between - */ - between(field: string, low: ValueType, high: ValueType): RdbPredicates; - - /** - * Configure RdbPredicates to match the specified field whose data type is int and value is - * out of a given range. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} low - Indicates the minimum value. - * @param {ValueType} high - Indicates the maximum value to. - * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.notBetween - */ - notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; - - /** - * Restricts the value of the field to be greater than the specified value. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.greaterThan - */ - greaterThan(field: string, value: ValueType): RdbPredicates; - - /** - * Restricts the value of the field to be smaller than the specified value. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.lessThan - */ - lessThan(field: string, value: ValueType): RdbPredicates; - - /** - * Restricts the value of the field to be greater than or equal to the specified value. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.greaterThanOrEqualTo - */ - greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; - - /** - * Restricts the value of the field to be smaller than or equal to the specified value. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.lessThanOrEqualTo - */ - lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; - - /** - * Restricts the ascending order of the return list. When there are several orders, - * the one close to the head has the highest priority. - * - * @param {string} field - Indicates the column name for sorting the return list. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.orderByAsc - */ - orderByAsc(field: string): RdbPredicates; - - /** - * Restricts the descending order of the return list. When there are several orders, - * the one close to the head has the highest priority. - * - * @param {string} field - Indicates the column name for sorting the return list. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.orderByDesc - */ - orderByDesc(field: string): RdbPredicates; - - /** - * Restricts each row of the query result to be unique. - * - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.distinct - */ - distinct(): RdbPredicates; - - /** - * Restricts the max number of return records. - * - * @param {number} value - Indicates the max length of the return list. - * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.limitAs - */ - limitAs(value: number): RdbPredicates; - - /** - * Configure RdbPredicatesV9 to specify the start position of the returned result. - * Use this method together with limit(int). - * - * @param {number} rowOffset - Indicates the start position of the returned result. The value is a positive integer. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.offsetAs - */ - offsetAs(rowOffset: number): RdbPredicates; - - /** - * Configure RdbPredicatesV9 to group query results by specified columns. - * - * @param {Array} fields - Indicates the specified columns by which query results are grouped. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.groupBy - */ - groupBy(fields: Array): RdbPredicates; - - /** - * Configure RdbPredicatesV9 to specify the index column. - * Before using this method, you need to create an index column. - * - * @param {string} field - Indicates the name of the index column. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.indexedBy - */ - indexedBy(field: string): RdbPredicates; - - /** - * Configure RdbPredicatesV9 to match the specified field whose data type is ValueType array and values - * are within a given range. - * - * @param {string} field - Indicates the column name in the database table. - * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 7 - * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.in - */ - in(field: string, value: Array): RdbPredicates; + /** + * Adds an or condition to the RdbPredicates. + * This method is similar to or of the SQL statement. + * + * @returns Returns the {@link RdbPredicates} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.or + */ + or(): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is ValueType array and values - * are out of a given range. + * Adds an and condition to the RdbPredicates. + * This method is similar to or of the SQL statement. * - * @param {string} field - Indicates the column name in the database table. - * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @returns Returns the {@link RdbPredicates} with the or condition. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.RdbPredicatesV9.notIn - */ - notIn(field: string, value: Array): RdbPredicates; -} - -/** - * Manages relational database configurations. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ -class RdbPredicatesV9 { - /** - * A parameterized constructor used to create an RdbPredicates instance. - * - * @param {string} name - Indicates the table name of the database. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - constructor(name: string) - - /** - * Sync data between devices. - * When query database, this function should not be called. - * - * @param {Array} devices - Indicates specified remote devices. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - inDevices(devices: Array): RdbPredicatesV9; - - /** - * Specify all remote devices which connect to local device when syncing distributed database. - * When query database, this function should not be called. - * - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - inAllDevices(): RdbPredicatesV9; - - /** - * Configure the RdbPredicatesV9 to match the field whose data type is ValueType and value is equal - * to a specified value. - * This method is similar to = of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - equalTo(field: string, value: ValueType): RdbPredicatesV9; - - /** - * Configure the RdbPredicatesV9 to match the field whose data type is ValueType and value is not equal to - * a specified value. - * This method is similar to != of the SQL statement. - * - * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - notEqualTo(field: string, value: ValueType): RdbPredicatesV9; - - /** - * Adds a left parenthesis to the RdbPredicatesV9. - * This method is similar to ( of the SQL statement and needs to be used together with endWrap(). - * - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} with the left parenthesis. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - beginWrap(): RdbPredicatesV9; - - /** - * Adds a right parenthesis to the RdbPredicatesV9. - * This method is similar to ) of the SQL statement and needs to be used together - * - * with beginWrap(). - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} with the right parenthesis. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - endWrap(): RdbPredicatesV9; - - /** - * Adds an or condition to the RdbPredicatesV9. - * This method is similar to or of the SQL statement. - * - * @returns Returns the {@link RdbPredicatesV9} with the or condition. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - or(): RdbPredicatesV9; - - /** - * Adds an and condition to the RdbPredicatesV9. - * This method is similar to or of the SQL statement. - * - * @returns Returns the {@link RdbPredicatesV9} with the or condition. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.and */ - and(): RdbPredicatesV9; + and(): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the field whose data type is string and value + * Configure the RdbPredicates to match the field whose data type is string and value * contains a specified value. * This method is similar to contains of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.contains */ - contains(field: string, value: string): RdbPredicatesV9; + contains(field: string, value: string): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the field whose data type is string and value starts + * Configure the RdbPredicates to match the field whose data type is string and value starts * with a specified string. * This method is similar to value% of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.beginsWith */ - beginsWith(field: string, value: string): RdbPredicatesV9; + beginsWith(field: string, value: string): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the field whose data type is string and value + * Configure the RdbPredicates to match the field whose data type is string and value * ends with a specified string. * This method is similar to %value of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.endsWith */ - endsWith(field: string, value: string): RdbPredicatesV9; + endsWith(field: string, value: string): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the fields whose value is null. + * Configure the RdbPredicates to match the fields whose value is null. * This method is similar to is null of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.isNull */ - isNull(field: string): RdbPredicatesV9; + isNull(field: string): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the specified fields whose value is not null. + * Configure the RdbPredicates to match the specified fields whose value is not null. * This method is similar to is not null of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.isNotNull */ - isNotNull(field: string): RdbPredicatesV9; + isNotNull(field: string): RdbPredicates; /** - * Configure the RdbPredicatesV9 to match the fields whose data type is string and value is + * Configure the RdbPredicates to match the fields whose data type is string and value is * similar to a specified string. * This method is similar to like of the SQL statement. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} that match the specified field. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} that match the specified field. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.like */ - like(field: string, value: string): RdbPredicatesV9; + like(field: string, value: string): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is string and the value contains + * Configure RdbPredicates to match the specified field whose data type is string and the value contains * a wildcard. * Different from like, the input parameters of this method are case-sensitive. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.glob */ - glob(field: string, value: string): RdbPredicatesV9; + glob(field: string, value: string): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is string and the value contains + * Configure RdbPredicates to match the specified field whose data type is string and the value contains * a wildcard. * * @param {string} field - Indicates the column name. * @param {ValueType} low - Indicates the minimum value. * @param {ValueType} high - Indicates the maximum value. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.between */ - between(field: string, low: ValueType, high: ValueType): RdbPredicatesV9; + between(field: string, low: ValueType, high: ValueType): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is int and value is + * Configure RdbPredicates to match the specified field whose data type is int and value is * out of a given range. * * @param {string} field - Indicates the column name in the database table. * @param {ValueType} low - Indicates the minimum value. * @param {ValueType} high - Indicates the maximum value to. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.notBetween */ - notBetween(field: string, low: ValueType, high: ValueType): RdbPredicatesV9; + notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; /** * Restricts the value of the field to be greater than the specified value. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.greaterThan */ - greaterThan(field: string, value: ValueType): RdbPredicatesV9; + greaterThan(field: string, value: ValueType): RdbPredicates; /** * Restricts the value of the field to be smaller than the specified value. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.lessThan */ - lessThan(field: string, value: ValueType): RdbPredicatesV9; + lessThan(field: string, value: ValueType): RdbPredicates; /** * Restricts the value of the field to be greater than or equal to the specified value. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.greaterThanOrEqualTo */ - greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicatesV9; + greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; /** * Restricts the value of the field to be smaller than or equal to the specified value. * * @param {string} field - Indicates the column name in the database table. - * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.lessThanOrEqualTo */ - lessThanOrEqualTo(field: string, value: ValueType): RdbPredicatesV9; + lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; /** * Restricts the ascending order of the return list. When there are several orders, * the one close to the head has the highest priority. * * @param {string} field - Indicates the column name for sorting the return list. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.orderByAsc */ - orderByAsc(field: string): RdbPredicatesV9; + orderByAsc(field: string): RdbPredicates; /** * Restricts the descending order of the return list. When there are several orders, * the one close to the head has the highest priority. * * @param {string} field - Indicates the column name for sorting the return list. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.orderByDesc */ - orderByDesc(field: string): RdbPredicatesV9; + orderByDesc(field: string): RdbPredicates; /** * Restricts each row of the query result to be unique. * - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.distinct */ - distinct(): RdbPredicatesV9; + distinct(): RdbPredicates; /** * Restricts the max number of return records. * * @param {number} value - Indicates the max length of the return list. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.limitAs */ - limitAs(value: number): RdbPredicatesV9; + limitAs(value: number): RdbPredicates; /** - * Configure RdbPredicatesV9 to specify the start position of the returned result. + * Configure RdbPredicates to specify the start position of the returned result. * Use this method together with limit(int). * * @param {number} rowOffset - Indicates the start position of the returned result. The value is a positive integer. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.offsetAs */ - offsetAs(rowOffset: number): RdbPredicatesV9; + offsetAs(rowOffset: number): RdbPredicates; /** - * Configure RdbPredicatesV9 to group query results by specified columns. + * Configure RdbPredicates to group query results by specified columns. * * @param {Array} fields - Indicates the specified columns by which query results are grouped. - * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.groupBy */ - groupBy(fields: Array): RdbPredicatesV9; + groupBy(fields: Array): RdbPredicates; /** - * Configure RdbPredicatesV9 to specify the index column. + * Configure RdbPredicates to specify the index column. * Before using this method, you need to create an index column. * * @param {string} field - Indicates the name of the index column. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.indexedBy */ - indexedBy(field: string): RdbPredicatesV9; + indexedBy(field: string): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * Configure RdbPredicates to match the specified field whose data type is ValueType array and values * are within a given range. * * @param {string} field - Indicates the column name in the database table. - * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {Array} value - Indicates the values to match with {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.in */ - in(field: string, value: Array): RdbPredicatesV9; + in(field: string, value: Array): RdbPredicates; /** - * Configure RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * Configure RdbPredicates to match the specified field whose data type is ValueType array and values * are out of a given range. * * @param {string} field - Indicates the column name in the database table. - * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. - * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. - * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @param {Array} value - Indicates the values to match with {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.relationalStore.RdbPredicates.notIn */ - notIn(field: string, value: Array): RdbPredicatesV9; + notIn(field: string, value: Array): RdbPredicates; } export type ResultSet = _ResultSet; -export type ResultSetV9 = _ResultSetV9; } export default rdb; diff --git a/api/@ohos.data.relationalStore.d.ts b/api/@ohos.data.relationalStore.d.ts new file mode 100644 index 0000000000..2e7b72e751 --- /dev/null +++ b/api/@ohos.data.relationalStore.d.ts @@ -0,0 +1,1332 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import{ AsyncCallback, Callback } from './basic'; +import Context from "./application/BaseContext"; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; + +/** + * Provides methods for rdbStore create and delete. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ +declare namespace relationalStore +{ + /** + * 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 RdbStore}. + * @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 getRdbStore(context: Context, config: StoreConfig, 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 RdbStore}. + * @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 getRdbStore(context: Context, config: StoreConfig): Promise; + + /** + * Deletes the database with a specified name. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @param {AsyncCallback} callback - the callback of deleteRdbStore. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed delete database by invalid database name + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function deleteRdbStore(context: Context, name: string, callback: AsyncCallback): void; + + /** + * Deletes the database with a specified name. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed delete database by invalid database name + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function deleteRdbStore(context: Context, name: string): Promise; + + /** + * Indicates the database synchronization mode. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + enum SyncMode { + /** + * Indicates the data is pushed to remote device from local device. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SYNC_MODE_PUSH = 0, + + /** + * Indicates the data is pulled from remote device to local device. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SYNC_MODE_PULL = 1, + } + + /** + * Describes the subscription type. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @permission ohos.permission.DISTRIBUTED_DATASYNC + */ + enum SubscribeType { + /** + * Subscription to remote data changes + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + SUBSCRIBE_TYPE_REMOTE = 0, + } + + /** + * Describes the {@code RdbStore} type. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + enum SecurityLevel { + /** + * 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). + * + * This class provides methods for creating, querying, updating, and deleting RDBs. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface RdbStore { + /** + * 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 RdbPredicates. + * + * @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 {RdbPredicates} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. + * @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: RdbPredicates, callback: AsyncCallback): void; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicates. + * + * @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 {RdbPredicates} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. + * @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: RdbPredicates): Promise; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicates. + * + * @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. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @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 RdbPredicates. + * + * @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. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @since 9 + */ + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicates. + * + * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}. + * @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: RdbPredicates, callback: AsyncCallback): void; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicates. + * + * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}. + * @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: RdbPredicates): Promise; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicates. + * + * @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. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @since 9 + */ + delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicates. + * + * @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. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @since 9 + */ + delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Queries data in the database based on specified conditions. + * + * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSet} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(predicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; + + /** + * Queries data in the database based on specified conditions. + * + * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSet} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + query(predicates: RdbPredicates, 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 ResultSet} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @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 ResultSet} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 202 - if permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @systemapi + * @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 {RdbPredicates} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicates}. + * @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 ResultSet} 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: RdbPredicates, 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 {RdbPredicates} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicates}. + * @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 ResultSet} 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: RdbPredicates, 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 ResultSet} 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 RdbPredicates. + * + * @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 ResultSet} 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 execute 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 executed. + * + * @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 executed. + * + * @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: RdbPredicates, 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: RdbPredicates): 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 + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + type ValueType = number | string | boolean | Uint8Array; + + /** + * Values in buckets are stored in key-value pairs + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + type ValuesBucket = { [key:string]: ValueType | Uint8Array | null;} + + /** + * Manages relational database configurations. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface StoreConfig { + /** + * The database name. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + name: string; + + /** + * Specifies whether the database is encrypted. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + securityLevel: SecurityLevel; + + /** + * Specifies whether the database is encrypted. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + encrypt ?: boolean; + } + + /** + * Manages relational database configurations. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + class RdbPredicates { + /** + * A parameterized constructor used to create an RdbPredicates instance. + * + * @param {string} name - Indicates the table name of the database. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + constructor(name: string) + + /** + * Sync data between devices. + * When query database, this function should not be called. + * + * @param {Array} devices - Indicates specified remote devices. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + inDevices(devices: Array): RdbPredicates; + + /** + * Specify all remote devices which connect to local device when syncing distributed database. + * When query database, this function should not be called. + * + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + inAllDevices(): RdbPredicates; + + /** + * Configure the RdbPredicates to match the field whose data type is ValueType and value is equal + * to a specified value. + * This method is similar to = of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + equalTo(field: string, value: ValueType): RdbPredicates; + + /** + * Configure the RdbPredicates to match the field whose data type is ValueType and value is not equal to + * a specified value. + * This method is similar to != of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notEqualTo(field: string, value: ValueType): RdbPredicates; + + /** + * Adds a left parenthesis to the RdbPredicates. + * This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * + * @returns {RdbPredicates} - the {@link RdbPredicates} with the left parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + beginWrap(): RdbPredicates; + + /** + * Adds a right parenthesis to the RdbPredicates. + * This method is similar to ) of the SQL statement and needs to be used together + * + * with beginWrap(). + * @returns {RdbPredicates} - the {@link RdbPredicates} with the right parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + endWrap(): RdbPredicates; + + /** + * Adds an or condition to the RdbPredicates. + * This method is similar to or of the SQL statement. + * + * @returns Returns the {@link RdbPredicates} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + or(): RdbPredicates; + + /** + * Adds an and condition to the RdbPredicates. + * This method is similar to or of the SQL statement. + * + * @returns Returns the {@link RdbPredicates} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + and(): RdbPredicates; + + /** + * Configure the RdbPredicates to match the field whose data type is string and value + * contains a specified value. + * This method is similar to contains of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + contains(field: string, value: string): RdbPredicates; + + /** + * Configure the RdbPredicates to match the field whose data type is string and value starts + * with a specified string. + * This method is similar to value% of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + beginsWith(field: string, value: string): RdbPredicates; + + /** + * Configure the RdbPredicates to match the field whose data type is string and value + * ends with a specified string. + * This method is similar to %value of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + endsWith(field: string, value: string): RdbPredicates; + + /** + * Configure the RdbPredicates to match the fields whose value is null. + * This method is similar to is null of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isNull(field: string): RdbPredicates; + + /** + * Configure the RdbPredicates to match the specified fields whose value is not null. + * This method is similar to is not null of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isNotNull(field: string): RdbPredicates; + + /** + * Configure the RdbPredicates to match the fields whose data type is string and value is + * similar to a specified string. + * This method is similar to like of the SQL statement. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} that match the specified field. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + like(field: string, value: string): RdbPredicates; + + /** + * Configure RdbPredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * Different from like, the input parameters of this method are case-sensitive. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + glob(field: string, value: string): RdbPredicates; + + /** + * Configure RdbPredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @param {string} field - Indicates the column name. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + between(field: string, low: ValueType, high: ValueType): RdbPredicates; + + /** + * Configure RdbPredicates to match the specified field whose data type is int and value is + * out of a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value to. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be greater than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + greaterThan(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + lessThan(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + orderByAsc(field: string): RdbPredicates; + + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + orderByDesc(field: string): RdbPredicates; + + /** + * Restricts each row of the query result to be unique. + * + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + distinct(): RdbPredicates; + + /** + * Restricts the max number of return records. + * + * @param {number} value - Indicates the max length of the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + limitAs(value: number): RdbPredicates; + + /** + * Configure RdbPredicates to specify the start position of the returned result. + * Use this method together with limit(int). + * + * @param {number} rowOffset - Indicates the start position of the returned result. The value is a positive integer. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + offsetAs(rowOffset: number): RdbPredicates; + + /** + * Configure RdbPredicates to group query results by specified columns. + * + * @param {Array} fields - Indicates the specified columns by which query results are grouped. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + groupBy(fields: Array): RdbPredicates; + + /** + * Configure RdbPredicates to specify the index column. + * Before using this method, you need to create an index column. + * + * @param {string} field - Indicates the name of the index column. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + indexedBy(field: string): RdbPredicates; + + /** + * Configure RdbPredicates to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + in(field: string, value: Array): RdbPredicates; + + /** + * Configure RdbPredicates to match the specified field whose data type is ValueType array and values + * are out of a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notIn(field: string, value: Array): RdbPredicates; + } + + /** + * Provides methods for accessing a database result set generated by querying the database. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface ResultSet { + + /** + * Obtains the names of all columns in a result set. + * The column names are returned as a string array, in which the strings are in the same order + * as the columns in the result set. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + columnNames: Array; + + /** + * Obtains the number of columns in the result set. + * The returned number is equal to the length of the string array returned by the + * columnCount method. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + columnCount: number; + + /** + * Obtains the number of rows in the result set. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + rowCount: number; + + /** + * Obtains the current index of the result set. + * The result set index starts from 0. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + rowIndex: number; + + /** + * Checks whether the result set is positioned at the first row. + * + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + isAtFirstRow: boolean; + + /** + * Checks whether the result set is positioned at the last row. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isAtLastRow: boolean; + + /** + * Checks whether the result set is positioned after the last row. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isEnded: boolean; + + /** + * Returns whether the cursor is pointing to the position before the first row. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isStarted: boolean; + + /** + * Checks whether the current result set is closed. + * + * If the result set is closed by calling the close method, true will be returned. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isClosed: boolean; + + /** + * Obtains the column index based on the specified column name. + * The column name is passed as an input parameter. + * + * @param {string} columnName - Indicates the name of the specified column in the result set. + * @returns {number} return the index of the specified column. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getColumnIndex(columnName: string): number; + + /** + * Obtains the column name based on the specified column index. + * The column index is passed as an input parameter. + * + * @param {number} columnIndex - Indicates the index of the specified column in the result set. + * @returns {string} returns the name of the specified column. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getColumnName(columnIndex: number): string; + + /** + * Go to the specified row of the result set forwards or backwards by an offset relative to its current position. + * A positive offset indicates moving backwards, and a negative offset indicates moving forwards. + * + * @param {number} offset - Indicates the offset relative to the current position. + * @returns {string} returns true if the result set is moved successfully and does not go beyond the range; + * returns false otherwise. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @throws {BusinessError} 401 - Parameter error. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goTo(offset: number): boolean; + + /** + * Go to the specified row of the result set. + * + * @param {number} rowIndex - Indicates the index of the specified row, which starts from 0. + * @returns {boolean} returns true if the result set is moved successfully; returns false otherwise. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @throws {BusinessError} 401 - Parameter error. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goToRow(position: number): boolean; + + /** + * Go to the first row of the result set. + * + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goToFirstRow(): boolean; + + /** + * Go to the last row of the result set. + * + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goToLastRow(): boolean; + + /** + * Go to the next row of the result set. + * + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the last row. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goToNextRow(): boolean; + + /** + * Go to the previous row of the result set. + * + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the first row. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + goToPreviousRow(): boolean; + + /** + * Obtains the value of the specified column in the current row as a byte array. + * The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null or the specified column is not of the Blob type. + * + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {Uint8Array} returns the value of the specified column as a byte array. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getBlob(columnIndex: number): Uint8Array; + + /** + * Obtains the value of the specified column in the current row as string. + * The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null or the specified column is not of the string type. + * + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {string} returns the value of the specified column as a string. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getString(columnIndex: number): string; + + /** + * Obtains the value of the specified column in the current row as long. + * The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null, the specified column is not of the integer type. + * + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a long. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getLong(columnIndex: number): number; + + /** + * Obtains the value of the specified column in the current row as double. + * The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null, the specified column is not of the double type. + * + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a double. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getDouble(columnIndex: number): number; + + /** + * Checks whether the value of the specified column in the current row is null. + * + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {boolean} returns true if the value of the specified column in the current row is null; + * returns false otherwise. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isColumnNull(columnIndex: number): boolean; + + /** + * Closes the result set. + * Calling this method on the result set will release all of its resources and makes it ineffective. + * + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + close(): void; + } +} + +export default relationalStore; diff --git a/api/data/rdb/resultSet.d.ts b/api/data/rdb/resultSet.d.ts index 6b07ec477c..4653017885 100644 --- a/api/data/rdb/resultSet.d.ts +++ b/api/data/rdb/resultSet.d.ts @@ -21,7 +21,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9 + * @useinstead ohos.data.relationalStore.ResultSet */ export interface ResultSet { @@ -33,7 +33,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.columnNames + * @useinstead ohos.data.relationalStore.ResultSet.columnNames */ columnNames: Array; @@ -45,7 +45,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.columnCount + * @useinstead ohos.data.relationalStore.ResultSet.columnCount */ columnCount: number; @@ -55,7 +55,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.rowCount + * @useinstead ohos.data.relationalStore.ResultSet.rowCount */ rowCount: number; @@ -66,7 +66,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.rowIndex + * @useinstead ohos.data.relationalStore.ResultSet.rowIndex */ rowIndex: number; @@ -76,7 +76,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isAtFirstRow + * @useinstead ohos.data.relationalStore.ResultSet.isAtFirstRow */ isAtFirstRow: boolean; @@ -86,7 +86,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isAtLastRow + * @useinstead ohos.data.relationalStore.ResultSet.isAtLastRow */ isAtLastRow: boolean; @@ -96,7 +96,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isEnded + * @useinstead ohos.data.relationalStore.ResultSet.isEnded */ isEnded: boolean; @@ -107,7 +107,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isStarted + * @useinstead ohos.data.relationalStore.ResultSet.isStarted */ isStarted: boolean; @@ -119,7 +119,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isClosed + * @useinstead ohos.data.relationalStore.ResultSet.isClosed */ isClosed: boolean; @@ -132,7 +132,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getColumnIndex + * @useinstead ohos.data.relationalStore.ResultSet.getColumnIndex */ getColumnIndex(columnName: string): number; @@ -145,7 +145,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getColumnName + * @useinstead ohos.data.relationalStore.ResultSet.getColumnName */ getColumnName(columnIndex: number): string; @@ -159,7 +159,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goTo + * @useinstead ohos.data.relationalStore.ResultSet.goTo */ goTo(offset: number): boolean; @@ -171,7 +171,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goToRow + * @useinstead ohos.data.relationalStore.ResultSet.goToRow */ goToRow(position: number): boolean; @@ -183,7 +183,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goToFirstRow + * @useinstead ohos.data.relationalStore.ResultSet.goToFirstRow */ goToFirstRow(): boolean; @@ -195,7 +195,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goToLastRow + * @useinstead ohos.data.relationalStore.ResultSet.goToLastRow */ goToLastRow(): boolean; @@ -207,7 +207,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goToNextRow + * @useinstead ohos.data.relationalStore.ResultSet.goToNextRow */ goToNextRow(): boolean; @@ -219,7 +219,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.goToPreviousRow + * @useinstead ohos.data.relationalStore.ResultSet.goToPreviousRow */ goToPreviousRow(): boolean; @@ -233,7 +233,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getBlob + * @useinstead ohos.data.relationalStore.ResultSet.getBlob */ getBlob(columnIndex: number): Uint8Array; @@ -247,7 +247,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getString + * @useinstead ohos.data.relationalStore.ResultSet.getString */ getString(columnIndex: number): string; @@ -261,7 +261,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getLong + * @useinstead ohos.data.relationalStore.ResultSet.getLong */ getLong(columnIndex: number): number; @@ -275,7 +275,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.getDouble + * @useinstead ohos.data.relationalStore.ResultSet.getDouble */ getDouble(columnIndex: number): number; @@ -288,7 +288,7 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.isColumnNull + * @useinstead ohos.data.relationalStore.ResultSet.isColumnNull */ isColumnNull(columnIndex: number): boolean; @@ -299,270 +299,8 @@ import { AsyncCallback } from '../../basic' * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 * @deprecated since 9 - * @useinstead ohos.data.rdb.ResultSetV9.close + * @useinstead ohos.data.relationalStore.ResultSet.close */ close(): void; } -/** - * Provides methods for accessing a database result set generated by querying the database. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - export interface ResultSetV9 { - - /** - * Obtains the names of all columns in a result set. - * The column names are returned as a string array, in which the strings are in the same order - * as the columns in the result set. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - columnNames: Array; - - /** - * Obtains the number of columns in the result set. - * The returned number is equal to the length of the string array returned by the - * columnCount method. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - */ - columnCount: number; - - /** - * Obtains the number of rows in the result set. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - rowCount: number; - - /** - * Obtains the current index of the result set. - * The result set index starts from 0. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - rowIndex: number; - - /** - * Checks whether the result set is positioned at the first row. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - */ - isAtFirstRow: boolean; - - /** - * Checks whether the result set is positioned at the last row. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - isAtLastRow: boolean; - - /** - * Checks whether the result set is positioned after the last row. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - isEnded: boolean; - - /** - * Returns whether the cursor is pointing to the position before the first row. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - isStarted: boolean; - - /** - * Checks whether the current result set is closed. - * - * If the result set is closed by calling the close method, true will be returned. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - isClosed: boolean; - - /** - * Obtains the column index based on the specified column name. - * The column name is passed as an input parameter. - * - * @param {string} columnName - Indicates the name of the specified column in the result set. - * @returns {number} return the index of the specified column. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - the parameter check failed. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getColumnIndex(columnName: string): number; - - /** - * Obtains the column name based on the specified column index. - * The column index is passed as an input parameter. - * - * @param {number} columnIndex - Indicates the index of the specified column in the result set. - * @returns {string} returns the name of the specified column. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getColumnName(columnIndex: number): string; - - /** - * Go to the specified row of the result set forwards or backwards by an offset relative to its current position. - * A positive offset indicates moving backwards, and a negative offset indicates moving forwards. - * - * @param {number} offset - Indicates the offset relative to the current position. - * @returns {string} returns true if the result set is moved successfully and does not go beyond the range; - * returns false otherwise. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goTo(offset: number): boolean; - - /** - * Go to the specified row of the result set. - * - * @param {number} rowIndex - Indicates the index of the specified row, which starts from 0. - * @returns {boolean} returns true if the result set is moved successfully; returns false otherwise. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goToRow(position: number): boolean; - - /** - * Go to the first row of the result set. - * - * @returns {boolean} returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is empty. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goToFirstRow(): boolean; - - /** - * Go to the last row of the result set. - * - * @returns {boolean} returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is empty. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goToLastRow(): boolean; - - /** - * Go to the next row of the result set. - * - * @returns {boolean} returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is already in the last row. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goToNextRow(): boolean; - - /** - * Go to the previous row of the result set. - * - * @returns {boolean} returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is already in the first row. - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - goToPreviousRow(): boolean; - - /** - * Obtains the value of the specified column in the current row as a byte array. - * The implementation class determines whether to throw an exception if the value of the specified column - * in the current row is null or the specified column is not of the Blob type. - * - * @param {number} columnIndex - Indicates the specified column index, which starts from 0. - * @returns {Uint8Array} returns the value of the specified column as a byte array. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401- Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getBlob(columnIndex: number): Uint8Array; - - /** - * Obtains the value of the specified column in the current row as string. - * The implementation class determines whether to throw an exception if the value of the specified column - * in the current row is null or the specified column is not of the string type. - * - * @param {number} columnIndex - Indicates the specified column index, which starts from 0. - * @returns {string} returns the value of the specified column as a string. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getString(columnIndex: number): string; - - /** - * Obtains the value of the specified column in the current row as long. - * The implementation class determines whether to throw an exception if the value of the specified column - * in the current row is null, the specified column is not of the integer type. - * - * @param {number} columnIndex - Indicates the specified column index, which starts from 0. - * @returns {number} returns the value of the specified column as a long. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getLong(columnIndex: number): number; - - /** - * Obtains the value of the specified column in the current row as double. - * The implementation class determines whether to throw an exception if the value of the specified column - * in the current row is null, the specified column is not of the double type. - * - * @param {number} columnIndex - Indicates the specified column index, which starts from 0. - * @returns {number} returns the value of the specified column as a double. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - getDouble(columnIndex: number): number; - - /** - * Checks whether the value of the specified column in the current row is null. - * - * @param {number} columnIndex - Indicates the specified column index, which starts from 0. - * @returns {boolean} returns true if the value of the specified column in the current row is null; - * returns false otherwise. - * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. - * @throws {BusinessError} 401 - Parameter error. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - isColumnNull(columnIndex: number): boolean; - - /** - * Closes the result set. - * Calling this method on the result set will release all of its resources and makes it ineffective. - * - * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 9 - */ - close(): void; -} \ No newline at end of file -- Gitee