@@ -4,7 +4,7 @@ The relational database (RDB) manages data based on relational models. With the
...
@@ -4,7 +4,7 @@ The relational database (RDB) manages data based on relational models. With the
This module provides the following RDB-related functions:
This module provides the following RDB-related functions:
-[RdbPredicates](#rdbpredicates): predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store.
-[RdbPredicates](#rdbpredicates): provides predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store.
-[RdbStore](#rdbstore): provides APIs for managing an RDB store.
-[RdbStore](#rdbstore): provides APIs for managing an RDB store.
> **NOTE**<br/>
> **NOTE**<br/>
...
@@ -166,14 +166,14 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
...
@@ -166,14 +166,14 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
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).
### insert
### insert
...
@@ -977,7 +979,7 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) {
...
@@ -977,7 +979,7 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) {
console.log("Failed to insert data");
console.log("Failed to insert data");
return;
return;
}
}
console.log("Inserted data, rowId = "+rowId);
console.log("Inserted data successfully, rowId = "+rowId);
| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. 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.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.|
...
@@ -1158,7 +1160,7 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr
...
@@ -1158,7 +1160,7 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. 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.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
@@ -1520,7 +1522,7 @@ Queries data from the RDB store of a remote device based on specified conditions
...
@@ -1520,7 +1522,7 @@ Queries data from the RDB store of a remote device based on specified conditions
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| device | string | Yes| Network ID of the remote device.|
| device | string | Yes| Network ID of the remote device.|
| table | string | Yes| Name of the target table.|
| table | string | Yes| Name of the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions for querying data.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
| columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
| columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md#resultset)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md#resultset)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
...
@@ -1553,7 +1555,7 @@ Queries data from the RDB store of a remote device based on specified conditions
...
@@ -1553,7 +1555,7 @@ Queries data from the RDB store of a remote device based on specified conditions
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| device | string | Yes| Network ID of the remote device.|
| device | string | Yes| Network ID of the remote device.|
| table | string | Yes| Name of the target table.|
| table | string | Yes| Name of the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions for querying data.|
| 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.|
| columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
@@ -1588,7 +1590,7 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca
...
@@ -1588,7 +1590,7 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| sql | string | Yes| SQL statement to run.|
| sql | string | Yes| SQL statement to run.|
| bindArgs | Array<[ValueType](#valuetype)> | Yes| Values of the parameters in the SQL statement.|
| bindArgs | Array<[ValueType](#valuetype)> | Yes| Arguments in the SQL statement.|
| 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.|
| 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**
**Example**
...
@@ -1608,7 +1610,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",
...
@@ -1608,7 +1610,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",
@@ -1680,14 +1682,14 @@ Executes an SQL statement that contains specified arguments but returns no value
...
@@ -1680,14 +1682,14 @@ Executes an SQL statement that contains specified arguments but returns no value
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise that returns no value.|
| Promise<void> | Promise used to return the result.|
**Example**
**Example**
```js
```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)"
constSQL_CREATE_TABLE="CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
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 an asynchronous callback to return the result.
Obtains the distributed table name for a remote device based on the local table name. This API uses an asynchronous callback to return the result. The distributed table name is required when the RDB store of a remote device is queried.
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.
Obtains the distributed table name for a remote device based on the local table name. This API uses a promise to return the result. The distributed table name is required when the RDB store of a remote device is queried.
@@ -2003,7 +2005,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
...
@@ -2003,7 +2005,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| **RdbPredicates** object that specifies the data and devices to synchronize.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| **RdbPredicates** object that specifies the data and devices to synchronize.|
| 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 each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
| 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. |
**Example**
**Example**
```js
```js
...
@@ -2042,7 +2044,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
...
@@ -2042,7 +2044,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| 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 each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
| 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. |