| context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
...
...
@@ -97,8 +156,38 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
| context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
| name | string | Yes| Name of the RDB store to delete.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
**Return value**
| Type| Description|
| -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.|
Before using the following APIs, use [executeSql](#executesql) to initialize the database table structure and related data. For details, see [RDB Development](../../database/database-relational-guidelines.md).
| table | string | Yes| Name of the target table.|
...
...
@@ -967,6 +1117,7 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Example**
```js
constvalueBucket={
"NAME":"Lisa",
...
...
@@ -983,7 +1134,6 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) {
| table | string | Yes| Name of the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Row of data to insert.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Example**
```js
constvalueBucket={
"NAME":"Lisa",
...
...
@@ -1028,6 +1181,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur
| table | string | Yes| Name of the target table.|
...
...
@@ -1035,6 +1189,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur
| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
**Example**
```js
constvalueBucket1={
"NAME":"Lisa",
...
...
@@ -1074,17 +1229,20 @@ Batch inserts data into a table. This API uses a promise to return the result.
| table | string | Yes| Name of the target table.|
| values | Array<[ValuesBucket](#valuesbucket)> | Yes| An array of data to insert.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
**Example**
```js
constvalueBucket1={
"NAME":"Lisa",
...
...
@@ -1123,13 +1281,15 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.|
**Example**
```js
constvalueBucket={
"NAME":"Rose",
...
...
@@ -1148,7 +1308,6 @@ rdbStore.update(valueBucket, predicates, function (err, ret) {
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the number of rows updated.|
| table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the number of rows updated.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
...
...
@@ -1395,6 +1580,7 @@ Queries data from the RDB store based on specified conditions. This API uses an
| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
| columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[ResultSet](js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| table | string | Yes| Name of the target table.|
...
...
@@ -1495,6 +1689,7 @@ Queries data from the RDB store based on specified conditions. This API uses a p
| Promise<[ResultSet](js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
@@ -1594,6 +1791,7 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example**
```js
rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",['sanguo'],function(err,resultSet){
if(err){
...
...
@@ -1605,7 +1803,6 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",
| bindArgs | Array<[ValueType](#valuetype)> | No| Arguments in the SQL statement.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[ResultSet](js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example**
```js
letpromise=rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",['sanguo'])
@@ -1653,6 +1853,7 @@ Executes an SQL statement that contains specified arguments but returns no value
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
**Example**
```js
constSQL_CREATE_TABLE="CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
| bindArgs | Array<[ValueType](#valuetype)> | No| Arguments in the SQL statement.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
```js
constSQL_CREATE_TABLE="CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
letpromise=rdbStore.executeSql(SQL_CREATE_TABLE)
...
...
@@ -1704,19 +1907,24 @@ Starts the transaction before executing an SQL statement.
@@ -1948,6 +2181,7 @@ Obtains the distributed table name for a remote device based on the local table
| callback | AsyncCallback<string> | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
...
...
@@ -2008,6 +2245,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
| callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
...
...
@@ -2047,6 +2285,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
| Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
| encrypt<sup>9+</sup> | boolean | No| Whether to encrypt the RDB store.<br>The value **true** means to encrypt the RDB store, and the value **false** means the opposite.|