diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md
index 53e3ca5aeaa25ecea55f3e27272043e6b533e594..df633d8449281b12557bb3d39f333f97148af1a4 100644
--- a/en/application-dev/database/database-relational-guidelines.md
+++ b/en/application-dev/database/database-relational-guidelines.md
@@ -7,7 +7,7 @@ A relational database (RDB) store allows you to operate local data with or witho
## Available APIs
-Most of the RDB store APIs are asynchronous interfaces, which can use a callback or promise to return the result. This document uses the promise-based APIs as an example. For details about the APIs, see [Relational Database](../reference/apis/js-apis-data-rdb.md).
+Most of the RDB store APIs are asynchronous interfaces, which can use a callback or promise to return the result. This document uses the promise-based APIs as an example. For more information about the APIs, see [RDB Store](../reference/apis/js-apis-data-relationalStore.md).
### Creating or Deleting an RDB Store
@@ -17,8 +17,8 @@ The following table describes the APIs for creating and deleting an RDB store.
| API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| getRdbStoreV9(context: Context, config: StoreConfigV9, version: number): Promise<RdbStoreV9> | Obtains an **RdbStoreV9** instance. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
- **context**: context of the application or function.
- **config**: configuration of the RDB store.
- **version**: version of the RDB store. Currently, automatic RDB upgrades and downgrades performed based on **version** is not supported.|
-| deleteRdbStoreV9(context: Context, name: string): Promise<void> | Deletes an RDB store. This API uses a promise to return the result.
- **context**: context of the application or function.
- **name**: name of the RDB store to delete.|
+| getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore> | Obtains an **RdbStore** object. This API uses a promise to return the result. You can set parameters for the **RdbStore** object based on service requirements and use **RdbStore** APIs to perform data operations.
- **context**: application context.
- **config**: configuration of the RDB store.|
+| deleteRdbStore(context: Context, name: string): Promise<void> | Deletes an RDB store. This API uses a promise to return the result.
- **context**: application context.
- **name**: name of the RDB store to delete.|
### Managing Data in an RDB Store
@@ -33,29 +33,29 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStoreV9 | insert(table: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.
- **table**: name of the target table.
- **values**: data to be inserted into the table.|
+ | RdbStore | insert(table: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.
- **table**: name of the target table.
- **values**: data to be inserted into the table.|
- **Updating Data**
- Call **update()** to update data based on the passed data and the conditions specified by **RdbPredicatesV9**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned.
+ Call **update()** to update data based on the passed data and the conditions specified by **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned.
**Table 3** API for updating data
- | Class | API | Description |
+ | Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStoreV9 | update(values: ValuesBucket, predicates: RdbPredicatesV9): Promise<number> | Updates data based on the specified **RdbPredicatesV9** object. This API uses a promise to return the number of rows updated.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data. |
+ | RdbStore | update(values: ValuesBucket, predicates: RdbPredicates): Promise<number> | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the number of rows updated.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data. |
- **Deleting Data**
- Call **delete()** to delete the data that meets the conditions specified by **RdbPredicatesV9**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned.
+ Call **delete()** to delete the data that meets the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned.
**Table 4** API for deleting data
- | Class | API | Description |
+ | Class | API | Description |
| ---------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
- | RdbStoreV9 | delete(predicates: RdbPredicatesV9): Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicatesV9** object. This API uses a promise to return the number of rows updated.
- **predicates**: conditions for deleting data. |
+ | RdbStore | delete(predicates: RdbPredicates): Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the number of rows deleted.
- **predicates**: conditions for deleting data. |
- **Querying Data**
@@ -66,50 +66,48 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 5** APIs for querying data
-
-| Class | API | Description |
-| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | query(predicates: RdbPredicatesV9, columns?: Array<string>): Promise<ResultSetV9> | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
-| RdbStoreV9 | querySql(sql: string, bindArgs?: Array<ValueType>): Promise<ResultSetV9> | Queries data using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.|
-| RdbStoreV9 | remoteQuery(device: string, table: string, predicates: RdbPredicatesV9, columns: Array<string>): Promise<ResultSetV9> | Queries data from the database of a remote device based on specified conditions. This API uses a promise to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to be queried.
- **predicates**: **RdbPredicatesV9** that specifies the query conditions.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
+ | Class | API | Description |
+ | ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+ | RdbStore | query(predicates: RdbPredicates, columns?: Array<string>): Promise<ResultSet> | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
+ | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>): Promise<ResultSet> | Queries data using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.|
+ | RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet> | Queries data from the database of a remote device based on specified conditions. This API uses a promise to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to be queried.
- **predicates**: **RdbPredicates** that specifies the query condition.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
### Using Predicates
-The **RDB** module provides **RdbPredicatesV9** for you to set database operation conditions.
+The **RDB** module provides **RdbPredicates** for you to set database operation conditions.
-The following table lists common predicates. For more information about predicates, see [**RdbPredicates**](../reference/apis/js-apis-data-rdb.md#rdbpredicates).
+The following table lists common predicates. For more information about predicates, see [**RdbPredicates**](../reference/apis/js-apis-data-relationalStore.md#rdbpredicates).
**Table 6** APIs for using RDB store predicates
-| Class | API | Description |
+| Class | API | Description |
| --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbPredicatesV9 | equalTo(field: string, value: ValueType): RdbPredicatesV9 | Sets an **RdbPredicatesV9** to search for the data that is equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match.
- **RdbPredicatesV9**: **RdbPredicatesV9** object created. |
-| RdbPredicatesV9 | notEqualTo(field: string, value: ValueType): RdbPredicatesV9 | Sets an **RdbPredicatesV9** to search for the data that is not equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match.
- **RdbPredicatesV9**: **RdbPredicatesV9** object created. |
-| RdbPredicatesV9 | or(): RdbPredicatesV9 | Adds the OR condition to the **RdbPredicatesV9**.
- **RdbPredicatesV9**: **RdbPredicatesV9** with the OR condition. |
-| RdbPredicatesV9 | and(): RdbPredicatesV9 | Adds the AND condition to the **RdbPredicatesV9**.
- **RdbPredicatesV9**: **RdbPredicatesV9** with the AND condition. |
-| RdbPredicatesV9 | contains(field: string, value: string): RdbPredicatesV9 | Sets an **RdbPredicatesV9** to search for the data that contains the specified value.
- **field**: column name in the database table.
- **value**: value to match.
- **RdbPredicatesV9**: **RdbPredicatesV9** object created. |
+| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to search for the data that is equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object created.|
+| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to search for the data that is not equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object created.|
+| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the OR condition.|
+| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the AND condition.|
+| RdbPredicates | contains(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to search for the data that contains the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object created.|
### Using the Result Set
-You can use the APIs provided by **ResultSetV9** to traverse and access the data you have queried. A result set can be regarded as a row of data in the queried result.
+You can use the APIs provided by **ResultSet** to traverse and access the data you have queried. A result set can be regarded as a row of data in the queried result.
-For details about how to use result set APIs, see [Result Set](../reference/apis/js-apis-data-resultset.md).
+For details about how to use **ResultSet** APIs, see [ResultSet](../reference/apis/js-apis-data-relationalStore.md#resultset).
-> **NOTICE**
->
+> **NOTICE**
> After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set
| Class | API | Description |
| ----------- | ---------------------------------------- | ------------------------------------------ |
-| ResultSetV9 | goToFirstRow(): boolean | Moves to the first row of the result set. |
-| ResultSetV9 | getString(columnIndex: number): string | Obtains the value in the form of a string based on the specified column and current row. |
-| ResultSetV9 | getBlob(columnIndex: number): Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
-| ResultSetV9 | getDouble(columnIndex: number): number | Obtains the value in the form of double based on the specified column and current row. |
-| ResultSetV9 | getLong(columnIndex: number): number | Obtains the value in the form of a long integer based on the specified column and current row. |
-| ResultSetV9 | close(): void | Closes the result set. |
+| ResultSet | goToFirstRow(): boolean | Moves to the first row of the result set. |
+| ResultSet | getString(columnIndex: number): string | Obtains the value in the form of a string based on the specified column and current row. |
+| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
+| ResultSet | getDouble(columnIndex: number): number | Obtains the value in the form of double based on the specified column and current row. |
+| ResultSet | getLong(columnIndex: number): number | Obtains the value in the form of a long integer based on the specified column and current row. |
+| ResultSet | close(): void | Closes the result set. |
@@ -117,7 +115,7 @@ For details about how to use result set APIs, see [Result Set](../reference/apis
> **NOTE**
>
-> - The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required for calling the **setDistributedTables**, **obtainDistributedTableName**, **sync**, **on** and **off** APIs of **RdbStore V9**.
+> - The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required for calling the **setDistributedTables**, **obtainDistributedTableName**, **sync**, **on** and **off** APIs of **RdbStore**.
> - The devices must be connected over network before the distributed tables are used. For details about the APIs and usage, see [Device Management](../reference/apis/js-apis-device-manager.md).
**Setting Distributed Tables**
@@ -126,7 +124,7 @@ For details about how to use result set APIs, see [Result Set](../reference/apis
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | setDistributedTables(tables: Array\): Promise\ | Sets distributed tables. This API uses a promise to return the result.
- **tables**: names of the distributed tables to set.|
+| RdbStore | setDistributedTables(tables: Array\): Promise\ | Sets distributed tables. This API uses a promise to return the result.
- **tables**: names of the distributed tables to set.|
**Obtaining the Distributed Table Name for a Remote Device**
@@ -136,7 +134,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried. This API uses a promise to return the result.
- **device**: remote device.
- **table**: local table name.|
+| RdbStore | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried. This API uses a promise to return the result.
- **device**: remote device.
- **table**: local table name.|
**Synchronizing Data Between Devices**
@@ -144,7 +142,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | sync(mode: SyncMode, predicates: RdbPredicatesV9): Promise\> | Synchronizes data between devices. This API uses a promise to return the result.
- **mode**: synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.
- **predicates**: specifies the data and devices to synchronize.
- **string**: device ID.
- **number**: synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure.|
+| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\> | Synchronizes data between devices. This API uses a promise to return the result.
- **mode**: synchronization mode. **SYNC_MODE_PUSH** means to push data from the local device to a remote device. **SYNC_MODE_PULL** means to pull data from a remote device to the local device.
- **predicates**: specifies the data and devices to synchronize.
- **string**: device ID.
- **number**: synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure.|
**Registering an RDB Store Observer**
@@ -152,7 +150,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | on(event: 'dataChange', type: SubscribeType, observer: Callback\>): void | Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE**: subscribes to remote data changes.
- **observer**: observer that listens for data changes in the RDB store.|
+| RdbStore | on(event: 'dataChange', type: SubscribeType, observer: Callback\>): void | Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE**: subscribes to remote data changes.
- **observer**: observer that listens for data changes in the RDB store.|
**Unregistering an RDB Store Observer**
@@ -160,7 +158,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStoreV9 | off(event:'dataChange', type: SubscribeType, observer: Callback\>): void; | Unregisters the observer of the specified type from the RDB store. This API uses an asynchronous callback to return the result.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE**: subscribes to remote data changes.
- **observer**: observer to unregister.|
+| RdbStore | off(event:'dataChange', type: SubscribeType, observer: Callback\>): void; | Unregisters the observer of the specified type from the RDB store. This API uses an asynchronous callback to return the result.
- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE**: subscribes to remote data changes.
- **observer**: observer to unregister.|
### Backing Up and Restoring an RDB Store
@@ -170,7 +168,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | --------------------------------------------- | ------------------------------------------------------------ |
-| RdbStoreV9 | backup(destName: string): Promise<void> | Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.|
+| RdbStore | backup(destName: string): Promise<void> | Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.|
**Restoring an RDB Store**
@@ -178,17 +176,17 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| ---------- | --------------------------------------------- | ------------------------------------------------------------ |
-| RdbStoreV9 | restore(srcName: string): Promise<void> | Restores an RDB store from a backup file. This API uses a promise to return the result.
- **srcName**: name of the backup file used to restore the RDB store.|
+| RdbStore | restore(srcName: string): Promise<void> | Restores an RDB store from a backup file. This API uses a promise to return the result.
- **srcName**: name of the backup file used to restore the RDB store.|
-**Transaction**
+### Transaction
Table 15 Transaction APIs
| Class | API | Description |
| -------- | ----------------------- | --------------------------------- |
-| RdbStoreV9 | beginTransaction(): void | Starts the transaction before executing SQL statements.|
-| RdbStoreV9 | commit(): void | Commits the executed SQL statements. |
-| RdbStoreV9 | rollBack(): void | Rolls back the SQL statements that have been executed. |
+| RdbStore | beginTransaction(): void | Starts the transaction before executing SQL statements.|
+| RdbStore | commit(): void | Commits the executed SQL statements. |
+| RdbStore | rollBack(): void | Rolls back the SQL statements that have been executed. |
## How to Develop
@@ -203,27 +201,27 @@ Table 15 Transaction APIs
FA model:
```js
- import data_rdb from '@ohos.data.rdb'
+ import data_rdb from '@ohos.data.relationalStore'
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext()
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
- const STORE_CONFIGV9 = { name: "RdbTest.db",
+ const STORE_CONFIG = { name: "RdbTest.db",
securityLevel: data_rdb.SecurityLevel.S1}
- data_rdb.getRdbStoreV9(context, STORE_CONFIGV9, 1, function (err, rdbStoreV9) {
- rdbStoreV9.executeSql(CREATE_TABLE_TEST)
+ data_rdb.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) {
+ rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
})
```
Stage model:
```ts
- import data_rdb from '@ohos.data.rdb'
+ import data_rdb from '@ohos.data.relationalStore'
// Obtain the context.
- import Ability from '@ohos.application.Ability'
+ import UIAbility from '@ohos.app.ability.UIAbility';
let context = null
- class MainAbility extends Ability {
+ class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
context = this.context
}
@@ -231,10 +229,10 @@ Table 15 Transaction APIs
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
- const STORE_CONFIGV9 = { name: "rdbstore.db",
+ const STORE_CONFIG = { name: "rdbstore.db",
securityLevel: data_rdb.SecurityLevel.S1}
- data_rdb.getRdbStoreV9(context, STORE_CONFIGV9, 1, function (err, rdbStoreV9) {
- rdbStoreV9.executeSql(CREATE_TABLE_TEST)
+ data_rdb.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) {
+ rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
})
```
@@ -248,14 +246,29 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- var u8 = new Uint8Array([1, 2, 3])
+ let u8 = new Uint8Array([1, 2, 3])
const valueBucket = { "name": "Tom", "age": 18, "salary": 100.5, "blobType": u8 }
- let insertPromise = rdbStoreV9.insert("test", valueBucket)
+ let insertPromise = rdbStore.insert("test", valueBucket)
+ ```
+
+ ```js
+ // Use a transaction to insert data.
+ beginTransaction()
+ try {
+ let u8 = new Uint8Array([1, 2, 3])
+ const valueBucket1 = { "name": "Tom", "age": 18, "salary": 100.5, "blobType": u8 }
+ const valueBucket2 = { "name": "Jam", "age": 19, "salary": 200.5, "blobType": u8 }
+ let insertPromise1 = rdbStore.insert("test", valueBucket1)
+ let insertPromise2 = rdbStore.insert("test", valueBucket2)
+ commit()
+ } catch (e) {
+ rollBack()
+ }
```
3. Query data.
- (1) Create an **RdbPredicatesV9** object to specify query conditions.
+ (1) Create an **RdbPredicates** object to specify query conditions.
(2) Call the **query()** API to query data.
@@ -264,17 +277,17 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let predicatesV9 = new data_rdb.RdbPredicatesV9("test");
- predicatesV9.equalTo("name", "Tom")
- let promisequery = rdbStoreV9.query(predicatesV9)
- promisequery.then((resultSetV9) => {
- resultSetV9.goToFirstRow()
- const id = resultSetV9.getLong(resultSetV9.getColumnIndex("id"))
- const name = resultSetV9.getString(resultSetV9.getColumnIndex("name"))
- const age = resultSetV9.getLong(resultSetV9.getColumnIndex("age"))
- const salary = resultSetV9.getDouble(resultSetV9.getColumnIndex("salary"))
- const blobType = resultSetV9.getBlob(resultSetV9.getColumnIndex("blobType"))
- resultSetV9.close()
+ let predicates = new data_rdb.RdbPredicates("test");
+ predicates.equalTo("name", "Tom")
+ let promisequery = rdbStore.query(predicates)
+ promisequery.then((resultSet) => {
+ resultSet.goToFirstRow()
+ const id = resultSet.getLong(resultSet.getColumnIndex("id"))
+ const name = resultSet.getString(resultSet.getColumnIndex("name"))
+ const age = resultSet.getLong(resultSet.getColumnIndex("age"))
+ const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
+ const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
+ resultSet.close()
})
```
@@ -302,7 +315,7 @@ Table 15 Transaction APIs
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
- let promise = rdbStoreV9.setDistributedTables(["test"])
+ let promise = rdbStore.setDistributedTables(["test"])
promise.then(() => {
console.info("setDistributedTables success.")
}).catch((err) => {
@@ -312,7 +325,7 @@ Table 15 Transaction APIs
5. Synchronize data across devices.
- (1) Construct an **RdbPredicatesV9** object to specify remote devices within the network to be synchronized.
+ (1) Construct an **RdbPredicates** object to specify remote devices within the network to be synchronized.
(2) Call **rdbStore.sync()** to synchronize data.
@@ -321,9 +334,9 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let predicateV9 = new data_rdb.RdbPredicatesV9('test')
- predicateV9.inDevices(['12345678abcde'])
- let promise = rdbStoreV9.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicateV9)
+ let predicate = new data_rdb.RdbPredicates('test')
+ predicate.inDevices(['12345678abcde'])
+ let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicate)
promise.then((result) => {
console.log('sync done.')
for (let i = 0; i < result.length; i++) {
@@ -350,7 +363,7 @@ Table 15 Transaction APIs
}
try {
- rdbStoreV9.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
+ rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
} catch (err) {
console.log('register observer failed')
}
@@ -365,8 +378,8 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let tableName = rdbStoreV9.obtainDistributedTableName(deviceId, "test");
- let resultSetV9 = rdbStoreV9.querySql("SELECT * FROM " + tableName)
+ let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
+ let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
```
8. Query data of a remote device.
@@ -379,17 +392,17 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let rdbPredicateV9 = new data_rdb.RdbPredicatesV9('employee')
- predicatesV9.greaterThan("id", 0)
- let promiseQuery = rdbStoreV9.remoteQuery('12345678abcde', 'employee', rdbPredicateV9)
- promiseQuery.then((resultSetV9) => {
- while (resultSetV9.goToNextRow()) {
- let idx = resultSetV9.getLong(0);
- let name = resultSetV9.getString(1);
- let age = resultSetV9.getLong(2);
+ let rdbPredicate = new data_rdb.RdbPredicates('employee')
+ predicates.greaterThan("id", 0)
+ let promiseQuery = rdbStore.remoteQuery('12345678abcde', 'employee', rdbPredicate)
+ promiseQuery.then((resultSet) => {
+ while (resultSet.goToNextRow()) {
+ let idx = resultSet.getLong(0);
+ let name = resultSet.getString(1);
+ let age = resultSet.getLong(2);
console.info(idx + " " + name + " " + age);
}
- resultSetV9.close();
+ resultSet.close();
}).catch((err) => {
console.info("failed to remoteQuery, err: " + err)
})
@@ -402,7 +415,7 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let promiseBackup = rdbStoreV9.backup("dbBackup.db")
+ let promiseBackup = rdbStore.backup("dbBackup.db")
promiseBackup.then(() => {
console.info('Backup success.')
}).catch((err) => {
@@ -414,7 +427,7 @@ Table 15 Transaction APIs
The sample code is as follows:
```js
- let promiseRestore = rdbStoreV9.restore("dbBackup.db")
+ let promiseRestore = rdbStore.restore("dbBackup.db")
promiseRestore.then(() => {
console.info('Restore success.')
}).catch((err) => {
diff --git a/en/application-dev/reference/apis/js-apis-data-relationalStore.md b/en/application-dev/reference/apis/js-apis-data-relationalStore.md
index 1d3451af2d899c34d1b73f2669c688cac7d6f464..e6b33f3544ead35cb0584365c1c806f02b30ad1f 100644
--- a/en/application-dev/reference/apis/js-apis-data-relationalStore.md
+++ b/en/application-dev/reference/apis/js-apis-data-relationalStore.md
@@ -62,8 +62,8 @@ data_rdb.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) {
console.info("Failed to get RdbStore, err: " + err)
return
}
- if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATA) {
- console.log("RdbStore status is ON_CREATA")
+ if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATE) {
+ console.log("RdbStore status is ON_CREATE")
} else if (rdbStore.openStatus == data_rdb.OpenStatus.ON_OPEN) {
console.log("RdbStore status is ON_OPEN")
} else {
@@ -97,8 +97,8 @@ data_rdb.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) {
console.info("Failed to get RdbStore, err: " + err)
return
}
- if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATA) {
- console.log("RdbStore status is ON_CREATA")
+ if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATE) {
+ console.log("RdbStore status is ON_CREATE")
} else if (rdbStore.openStatus == data_rdb.OpenStatus.ON_OPEN) {
console.log("RdbStore status is ON_OPEN")
} else {
@@ -154,8 +154,8 @@ const STORE_CONFIG = {
}
let promise = data_rdb.getRdbStore(context, STORE_CONFIG);
promise.then(async (rdbStore) => {
- if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATA) {
- console.log("RdbStore status is ON_CREATA")
+ if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATE) {
+ console.log("RdbStore status is ON_CREATE")
} else if (rdbStore.openStatus == data_rdb.OpenStatus.ON_OPEN) {
console.log("RdbStore status is ON_OPEN")
} else {
@@ -188,8 +188,8 @@ const STORE_CONFIG = {
}
let promise = data_rdb.getRdbStore(context, STORE_CONFIG);
promise.then(async (rdbStore) => {
- if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATA) {
- console.log("RdbStore status is ON_CREATA")
+ if (rdbStore.openStatus == data_rdb.OpenStatus.ON_CREATE) {
+ console.log("RdbStore status is ON_CREATE")
} else if (rdbStore.openStatus == data_rdb.OpenStatus.ON_OPEN) {
console.log("RdbStore status is ON_OPEN")
} else {
diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md
index 798ac7bba0926f47e1bc16eb6b672403bc082fa7..8cdecd1134a270075b3d4dd86a7e4e7a07fc7390 100644
--- a/en/application-dev/reference/apis/js-apis-data-resultset.md
+++ b/en/application-dev/reference/apis/js-apis-data-resultset.md
@@ -1,549 +1,17 @@
-# Result Set
+# resultSet
A result set is a set of results returned after the relational database (RDB) query APIs are called. You can use the **resultset** APIs to obtain required data.
-> **NOTE**
+> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The APIs of this module are no longer maintained since API version 9. You are advised to use [@ohos.data.relationalStore#ResultSet](js-apis-data-relationalStore.md#resultset).
-## ResultSetV99+
-
-Provides methods to access the result set, which is obtained by querying the RDB store.
-
-### Usage
-
-You need to obtain the **resultSetV9** instance by using [RdbStoreV9.query()](js-apis-data-rdb.md#query).
-
-```js
-import dataRdb from '@ohos.data.rdb';
-let predicatesV9 = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-predicatesV9.equalTo("AGE", 18);
-let promise = rdbStoreV9.query(predicatesV9, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promise.then((resultSetV9) => {
- console.log(TAG + "resultSet columnNames:" + resultSetV9.columnNames);
- console.log(TAG + "resultSet columnCount:" + resultSetV9.columnCount);
-});
-```
-
-### Attributes9+
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-| Name | Type | Mandatory| Description |
-| ------------ | ------------------- | ---- | -------------------------------- |
-| columnNames | Array<string> | Yes | Names of all columns in the result set. |
-| columnCount | number | Yes | Number of columns in the result set. |
-| rowCount | number | Yes | Number of rows in the result set. |
-| rowIndex | number | Yes | Index of the current row in the result set. |
-| isAtFirstRow | boolean | Yes | Whether the cursor is in the first row of the result set. |
-| isAtLastRow | boolean | Yes | Whether the cursor is in the last row of the result set. |
-| isEnded | boolean | Yes | Whether the cursor is after the last row of the result set.|
-| isStarted | boolean | Yes | Whether the cursor has been moved. |
-| isClosed | boolean | Yes | Whether the result set is closed. |
-
-### getColumnIndex9+
-
-getColumnIndex(columnName: string): number
-
-Obtains the column index based on the column name.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ---------- | ------ | ---- | -------------------------- |
-| columnName | string | Yes | Column name specified.|
-
-**Return value**
-
-| Type | Description |
-| ------ | ------------------ |
-| number | Index of the column obtained.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-resultSetV9.goToFirstRow();
-const id = resultSetV9.getLong(resultSetV9.getColumnIndex("ID"));
-const name = resultSetV9.getString(resultSetV9.getColumnIndex("NAME"));
-const age = resultSetV9.getLong(resultSetV9.getColumnIndex("AGE"));
-const salary = resultSetV9.getDouble(resultSetV9.getColumnIndex("SALARY"));
- ```
-
-### getColumnName9+
-
-getColumnName(columnIndex: number): string
-
-Obtains the column name based on the column index.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | -------------------------- |
-| columnIndex | number | Yes | Column index specified.|
-
-**Return value**
-
-| Type | Description |
-| ------ | ------------------ |
-| string | Column name obtained.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const id = resultSetV9.getColumnName(0);
-const name = resultSetV9.getColumnName(1);
-const age = resultSetV9.getColumnName(2);
- ```
-
-### goTo9+
-
-goTo(offset:number): boolean
-
-Moves the cursor to the row based on the specified offset.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ---------------------------- |
-| offset | number | Yes | Offset relative to the current position.|
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9goto = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygoto = rdbStoreV9.query(predicatesV9goto, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygoto.then((resultSetV9) => {
- resultSetV9.goTo(1);
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### goToRow9+
-
-goToRow(position: number): boolean
-
-Moves the cursor to the specified row in the result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ------ | ---- | ------------------------ |
-| position | number | Yes | Position to which the cursor is to be moved.|
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9gotorow = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygotorow = rdbStoreV9.query(predicatesV9gotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygotorow.then((resultSetV9) => {
- resultSetV9.goToRow(5);
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### goToFirstRow9+
-
-goToFirstRow(): boolean
-
-
-Moves the cursor to the first row of the result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9goFirst = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygoFirst = rdbStoreV9.query(predicatesV9goFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygoFirst.then((resultSetV9) => {
- resultSetV9.goToFirstRow();
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### goToLastRow9+
-
-goToLastRow(): boolean
-
-Moves the cursor to the last row of the result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9goLast = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygoLast = rdbStoreV9.query(predicatesV9goLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygoLast.then((resultSetV9) => {
- resultSetV9.goToLastRow();
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### goToNextRow9+
-
-goToNextRow(): boolean
-
-Moves the cursor to the next row in the result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9goNext = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygoNext = rdbStoreV9.query(predicatesV9goNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygoNext.then((resultSetV9) => {
- resultSetV9.goToNextRow();
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### goToPreviousRow9+
-
-goToPreviousRow(): boolean
-
-Moves the cursor to the previous row in the result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-**Example**
-
- ```js
-let predicatesV9goPrev = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promisequerygoPrev = rdbStoreV9.query(predicatesV9goPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promisequerygoPrev.then((resultSetV9) => {
- resultSetV9.goToPreviousRow();
- resultSetV9.close();
-}).catch((err) => {
- console.log('query failed');
-});
- ```
-
-### getBlob9+
-
-getBlob(columnIndex: number): Uint8Array
-
-Obtains the value in the specified column in the current row as a byte array.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | ----------------------- |
-| columnIndex | number | Yes | Index of the specified column, starting from 0.|
-
-**Return value**
-
-| Type | Description |
-| ---------- | -------------------------------- |
-| Uint8Array | Value in the specified column as a byte array.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const codes = resultSetV9.getBlob(resultSetV9.getColumnIndex("CODES"));
- ```
-
-### getString9+
-
-getString(columnIndex: number): string
-
-Obtains the value in the specified column in the current row as a string.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | ----------------------- |
-| columnIndex | number | Yes | Index of the specified column, starting from 0.|
-
-**Return value**
-
-| Type | Description |
-| ------ | ---------------------------- |
-| string | Value in the specified column as a string.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const name = resultSetV9.getString(resultSetV9.getColumnIndex("NAME"));
- ```
-
-### getLong9+
-
-getLong(columnIndex: number): number
-
-Obtains the value in the specified column in the current row as a Long.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | ----------------------- |
-| columnIndex | number | Yes | Index of the specified column, starting from 0.|
-
-**Return value**
-
-| Type | Description |
-| ------ | -------------------------- |
-| number | Value in the specified column as a Long.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const age = resultSetV9.getLong(resultSetV9.getColumnIndex("AGE"));
- ```
-
-### getDouble9+
-
-getDouble(columnIndex: number): number
-
-Obtains the value in the specified column in the current row as a double.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | ----------------------- |
-| columnIndex | number | Yes | Index of the specified column, starting from 0.|
-
-**Return value**
-
-| Type | Description |
-| ------ | ---------------------------- |
-| number | Value in the specified column as a double.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const salary = resultSetV9.getDouble(resultSetV9.getColumnIndex("SALARY"));
- ```
-
-### isColumnNull9+
-
-isColumnNull(columnIndex: number): boolean
-
-Checks whether the value in the specified column of the current row is null.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | ------ | ---- | ----------------------- |
-| columnIndex | number | Yes | Index of the specified column, starting from 0.|
-
-**Return value**
-
-| Type | Description |
-| ------- | --------------------------------------------------------- |
-| boolean | Returns **true** if the value is null; returns **false** otherwise.|
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800013 | The column value is null or the column type is incompatible. |
-
-**Example**
-
- ```js
-const isColumnNull = resultSetV9.isColumnNull(resultSetV9.getColumnIndex("CODES"));
- ```
-
-### close9+
-
-close(): void
-
-Closes this result set.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Example**
-
- ```js
-let predicatesV9Close = new dataRdb.RdbPredicatesV9("EMPLOYEE");
-let promiseClose = rdbStoreV9.query(predicatesV9Close, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
-promiseClose.then((resultSetV9) => {
- resultSetV9.close();
-}).catch((err) => {
- console.log('Failed to close the resultset');
-});
- ```
-
-**Error codes**
-
-For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
-
-| ID| **Error Message** |
-| ------------ | ------------------------------------------------------------ |
-| 14800012 | The result set is empty or the specified location is invalid. |
-
-## ResultSet(deprecated)
+## ResultSet
Provides methods to access the result set, which is obtained by querying the RDB store.
-> **NOTE**
->
-> This object is supported since API version 7 and deprecated since API version 9. You are advised to use [ResultSetV9](#resultsetv99).
-
### Usage
You need to obtain a **resultSet** object by using [RdbStore.query()](js-apis-data-rdb.md#query).
@@ -559,11 +27,7 @@ promise.then((resultSet) => {
});
```
-### Attributes(deprecated)
-
-> **NOTE**
->
-> This parameter is supported since API version 7 and is deprecated since API version 9. You are advised to use [Attributes](#attributes9).
+### Attributes
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -579,29 +43,25 @@ promise.then((resultSet) => {
| isStarted | boolean | Yes| Whether the cursor has been moved.|
| isClosed | boolean | Yes| Whether the result set is closed.|
-### getColumnIndex(deprecated)
+### getColumnIndex
getColumnIndex(columnName: string): number
Obtains the column index based on the column name.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getColumnIndex](#getcolumnindex9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnName | string | Yes| Column name specified.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnName | string | Yes| Column name specified.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| number | Index of the column obtained.|
+ | Type| Description|
+ | -------- | -------- |
+ | number | Index of the column obtained.|
**Example**
@@ -613,29 +73,25 @@ Obtains the column index based on the column name.
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
```
-### getColumnName(deprecated)
+### getColumnName
getColumnName(columnIndex: number): string
Obtains the column name based on the column index.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getColumnName](#getcolumnname9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Column index specified.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Column index specified.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| string | Column name obtained.|
+ | Type| Description|
+ | -------- | -------- |
+ | string | Column name obtained.|
**Example**
@@ -645,29 +101,25 @@ Obtains the column name based on the column index.
const age = resultSet.getColumnName(2);
```
-### goTo(deprecated)
+### goTo
goTo(offset:number): boolean
Moves the cursor to the row based on the specified offset.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goTo](#goto9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| offset | number | Yes| Offset relative to the current position.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | offset | number | Yes| Offset relative to the current position.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -682,29 +134,25 @@ Moves the cursor to the row based on the specified offset.
});
```
-### goToRow(deprecated)
+### goToRow
goToRow(position: number): boolean
Moves the cursor to the specified row in the result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToRow](#gotorow9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| position | number | Yes| Position to which the cursor is to be moved.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | position | number | Yes| Position to which the cursor is to be moved.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -719,23 +167,19 @@ Moves the cursor to the specified row in the result set.
});
```
-### goToFirstRow(deprecated)
+### goToFirstRow
goToFirstRow(): boolean
Moves the cursor to the first row of the result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToFirstRow](#gotofirstrow9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -750,23 +194,19 @@ Moves the cursor to the first row of the result set.
});
```
-### goToLastRow(deprecated)
+### goToLastRow
goToLastRow(): boolean
Moves the cursor to the last row of the result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToLastRow](#gotolastrow9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -781,23 +221,19 @@ Moves the cursor to the last row of the result set.
});
```
-### goToNextRow(deprecated)
+### goToNextRow
goToNextRow(): boolean
Moves the cursor to the next row in the result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToNextRow](#gotonextrow9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -812,23 +248,19 @@ Moves the cursor to the next row in the result set.
});
```
-### goToPreviousRow(deprecated)
+### goToPreviousRow
goToPreviousRow(): boolean
Moves the cursor to the previous row in the result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [goToPreviousRow](#gotopreviousrow9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
@@ -843,29 +275,25 @@ Moves the cursor to the previous row in the result set.
});
```
-### getBlob(deprecated)
+### getBlob
getBlob(columnIndex: number): Uint8Array
Obtains the value in the specified column in the current row as a byte array.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getBlob](#getblob9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Index of the specified column, starting from 0.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Uint8Array | Value in the specified column as a byte array.|
+ | Type| Description|
+ | -------- | -------- |
+ | Uint8Array | Value in the specified column as a byte array.|
**Example**
@@ -873,29 +301,25 @@ Obtains the value in the specified column in the current row as a byte array.
const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES"));
```
-### getString(deprecated)
+### getString
getString(columnIndex: number): string
Obtains the value in the specified column in the current row as a string.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getString](#getstring9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Index of the specified column, starting from 0.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| string | Value in the specified column as a string.|
+ | Type| Description|
+ | -------- | -------- |
+ | string | Value in the specified column as a string.|
**Example**
@@ -903,29 +327,25 @@ Obtains the value in the specified column in the current row as a string.
const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
```
-### getLong(deprecated)
+### getLong
getLong(columnIndex: number): number
Obtains the value in the specified column in the current row as a Long.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getLong](#getlong9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Index of the specified column, starting from 0.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| number | Value in the specified column as a Long.|
+ | Type| Description|
+ | -------- | -------- |
+ | number | Value in the specified column as a Long.|
**Example**
@@ -933,29 +353,25 @@ Obtains the value in the specified column in the current row as a Long.
const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
```
-### getDouble(deprecated)
+### getDouble
getDouble(columnIndex: number): number
Obtains the value in the specified column in the current row as a double.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDouble](#getdouble9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Index of the specified column, starting from 0.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| number | Value in the specified column as a double.|
+ | Type| Description|
+ | -------- | -------- |
+ | number | Value in the specified column as a double.|
**Example**
@@ -963,29 +379,25 @@ Obtains the value in the specified column in the current row as a double.
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
```
-### isColumnNull(deprecated)
+### isColumnNull
isColumnNull(columnIndex: number): boolean
Checks whether the value in the specified column of the current row is null.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isColumnNull](#iscolumnnull9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| columnIndex | number | Yes| Index of the specified column, starting from 0.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | columnIndex | number | Yes| Index of the specified column, starting from 0.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| boolean | Returns **true** if the value is null; returns **false** otherwise.|
+ | Type| Description|
+ | -------- | -------- |
+ | boolean | Returns **true** if the value is null; returns **false** otherwise.|
**Example**
@@ -993,16 +405,12 @@ Checks whether the value in the specified column of the current row is null.
const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES"));
```
-### close(deprecated)
+### close
close(): void
Closes this result set.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [close](#close9).
-
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Example**