@@ -6,7 +6,7 @@ The **relationalStore** module provides the following functions:
...
@@ -6,7 +6,7 @@ The **relationalStore** module provides the following functions:
-[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.
-[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 data in an RDB store.
-[RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
-[ResultSet](#resultset): provides APIs for accessing the result set obtained from the RDB store.
-[Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
> **NOTE**
> **NOTE**
>
>
...
@@ -39,10 +39,10 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
...
@@ -39,10 +39,10 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| 14800010 | Failed to open or delete database by invalid database path. |
| 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | The inner error is occurred. |
| 14800000 | Inner error. |
**Example**
**Example**
...
@@ -323,7 +323,7 @@ Enumerates the RDB store security levels.
...
@@ -323,7 +323,7 @@ Enumerates the RDB store security levels.
> **NOTE**
> **NOTE**
>
>
> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Access Control Mechanism in Cross-Device Synchronization](../../database/access-control-by-device-and-data-level.md#access-control-mechanism-in-cross-device-synchronization).
> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Cross-Device Data Synchronization Mechanism]( ../../database/sync-app-data-across-devices-overview.md#cross-device-data-synchronization-mechanism).
| ON_CONFLICT_NONE | 0 | No operation is performed.|
| ON_CONFLICT_ROLLBACK | 1 | Abort the SQL statement and roll back the current transaction. |
| ON_CONFLICT_ABORT | 2 | Abort the current SQL statement and revert any changes made by the current SQL statement. However, the changes made by the previous SQL statement in the same transaction are retained and the transaction remains active.|
| ON_CONFLICT_FAIL | 3 | Abort the current SQL statement. The **FAIL** resolution does not revert previous changes made by the failed SQL statement or end the transaction.|
| ON_CONFLICT_IGNORE | 4 | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
| ON_CONFLICT_REPLACE | 5 | Delete pre-existing rows that cause the constraint violation before inserting or updating the current row, and continue to execute the command normally.|
## RdbPredicates
## RdbPredicates
Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. This type is not multi-thread safe. If a **RdbPredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. This type is not multi-thread safe. If an**RdbPredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
@@ -1257,6 +1290,15 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
...
@@ -1257,6 +1290,15 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. |
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. |
| 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.|
| 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.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| table | string | Yes | Name of the target table. |
| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
| 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.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| 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.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows updated. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| 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.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. |
| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. |
| Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example**
**Example**
...
@@ -1881,8 +2126,17 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
...
@@ -1881,8 +2126,17 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
> **NOTE**
> **NOTE**<br/>
>
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...
@@ -2009,8 +2281,8 @@ Queries data from the RDB store of a remote device based on specified conditions
...
@@ -2009,8 +2281,8 @@ Queries data from the RDB store of a remote device based on specified conditions
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
> **NOTE**
> **NOTE**<br/>
>
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...
@@ -2075,8 +2356,8 @@ Queries data from the RDB store of a remote device based on specified conditions
...
@@ -2075,8 +2356,8 @@ Queries data from the RDB store of a remote device based on specified conditions
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. |
| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. |
| type | [SubscribeType](#subscribetype) | Yes | Subscription type to register.|
| type | [SubscribeType](#subscribetype) | Yes | Subscription type to register.|
| observer | Callback<Array<string>> | Yes | Callback invoked to return the data change. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
| observer | Callback<Array<string>> | Yes | Callback invoked to return the data change event. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
**Example**
**Example**
...
@@ -2885,9 +3196,9 @@ Unregisters the observer of the specified type from the RDB store. This API uses
...
@@ -2885,9 +3196,9 @@ Unregisters the observer of the specified type from the RDB store. This API uses
| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. |
| event | string | Yes | Event type. The value is **dataChange**, which indicates a data change event. |
| type | [SubscribeType](#subscribetype) | Yes | Subscription type to unregister. |
| type | [SubscribeType](#subscribetype) | Yes | Subscription type to unregister. |
| observer | Callback<Array<string>> | Yes | Callback for the data change. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
| observer | Callback<Array<string>> | Yes | Callback for the data change event. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
**Example**
**Example**
...
@@ -3040,7 +3351,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
...
@@ -3040,7 +3351,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| number | Value obtained.<br>The value range supported by this API is **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. If the value is out of this range, use [getDouble](#getdouble).|
| number | Value obtained.<br>The value range supported by API is **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. If the value is out of this range, use [getDouble](#getdouble).|
**Error codes**
**Error codes**
...
@@ -3433,4 +3744,4 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
...
@@ -3433,4 +3744,4 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode