You need to sign in or sign up before continuing.
未验证 提交 f2860899 编写于 作者: O openharmony_ci 提交者: Gitee

!19343 挑单4.1 Beta1

Merge pull request !19343 from Annie_wang/cherry-pick-1686130203
...@@ -244,6 +244,7 @@ ...@@ -244,6 +244,7 @@
- [PermissionRequestResult](js-apis-permissionrequestresult.md) - [PermissionRequestResult](js-apis-permissionrequestresult.md)
- Data Management - Data Management
- [@ohos.data.cloudData (Device-Cloud Synergy)](js-apis-data-cloudData.md)
- [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md) - [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
- [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md) - [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates (DataShare Predicates)](js-apis-data-dataSharePredicates.md) - [@ohos.data.dataSharePredicates (DataShare Predicates)](js-apis-data-dataSharePredicates.md)
......
# @ohos.data.cloudData (Device-Cloud Synergy)
The **cloudData** module provides the capability of synchronizing the structured data (in RDB stores) between the device and cloud. The cloud serves as the central node of data. The devices synchronize data with the data in the cloud to implement cloud data backup and data consistency between the devices with the same account.
This module provides the following common functions:
- [Config](#config): provides methods for configuring device-cloud synergy, including enabling and disabling cloud synchronization, clearing data, and notifying data changes.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import cloudData from '@ohos.data.cloudData';
```
## Action
Enumerates the actions for clearing the cloud information about the local data.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
| Name | Description |
| --------- | ---------------------------- |
| CLEAR_CLOUD_INFO | Clear the cloud ID information.|
| CLEAR_CLOUD_DATA_AND_INFO |Clear all cloud data, including cloud ID information and data downloaded from the cloud (excluding the data modified or generated locally). |
## Config
Provides methods for configuring device-cloud synergy, including enabling and disabling cloud synchronization, clearing data, and notifying data changes.
### enableCloud
static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, callback: AsyncCallback<void>):void
Enables device-cloud synergy. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | Yes | ID of the target cloud. |
| switches | {[bundleName: string]: boolean} | Yes | Device-cloud synergy switches for applications. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let switches = { 'test_bundleName1': true, 'test_bundleName2': false };
try {
cloudData.Config.enableCloud(account, switches, function (err) {
if (err === undefined) {
console.info('Succeeded in enabling cloud');
} else {
console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### enableCloud
static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}): Promise<void>
Enables device-cloud synergy. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | Yes | ID of the target cloud. |
| switches | {[bundleName: string]: boolean} | Yes | Device-cloud synergy switches for applications. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let switches = { 'test_bundleName1': true, 'test_bundleName2': false };
try {
cloudData.Config.enableCloud(account, switches).then(() => {
console.info('Succeeded in enabling cloud');
}).catch((err) => {
console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### disableCloud
static disableCloud(accountId: string, callback: AsyncCallback<void>):void
Disables device-cloud synergy. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
try {
cloudData.Config.disableCloud(account, function (err) {
if (err === undefined) {
console.info('Succeeded in disabling cloud');
} else {
console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### disableCloud
static disableCloud(accountId: string): Promise<void>
Disables device-cloud synergy. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
try {
cloudData.Config.disableCloud(account).then(() => {
console.info('Succeeded in disabling cloud');
}).catch((err) => {
console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### changeAppCloudSwitch
static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, callback: AsyncCallback<void>):void
Changes the device-cloud synergy switch for an application. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName| string | Yes | Name of the target application.|
| status | boolean | Yes | Setting of the device-cloud synergy switch for the application. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.changeAppCloudSwitch(account, bundleName, true, function (err) {
if (err === undefined) {
console.info('Succeeded in changing App cloud switch');
} else {
console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### changeAppCloudSwitch
static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): Promise<void>
Changes the device-cloud synergy switch for an application. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName| string | Yes | Name of the target application.|
| status | boolean | Yes | Setting of the device-cloud synergy switch for the application. The value **true** means to enable the device-cloud synergy; the value **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
console.info('Succeeded in changing App cloud switch');
}).catch((err) => {
console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### notifyDataChange
static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCallback<void>):void
Notifies the data changes in the cloud. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName | string | Yes | Name of the target application. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.notifyDataChange(account, bundleName, function (err) {
if (err === undefined) {
console.info('Succeeded in notifying the change of data');
} else {
console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
}
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
### notifyDataChange
static notifyDataChange(accountId: string,bundleName:string): Promise<void>
Notifies the data changes in the cloud. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------- |
| accountId | string | Yes | ID of the target cloud.|
| bundleName | string | Yes | Name of the target application. |
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
**Example**
```js
let account = 'test_id';
let bundleName = 'test_bundleName';
try {
cloudData.Config.notifyDataChange(account, bundleName).then(() => {
console.info('Succeeded in notifying the change of data');
}).catch((err) => {
console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
});
} catch (error) {
console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
}
```
# @ohos.data.dataSharePredicates (DataShare Predicates) # @ohos.data.dataSharePredicates (Data Share Predicates)
You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data. You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data.
...@@ -18,13 +18,13 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; ...@@ -18,13 +18,13 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates';
``` ```
## DataSharePredicates ## DataSharePredicates
Provides methods for setting different **DataSharePredicates** objects. Provides methods for setting different **DataSharePredicates** objects. This type is not multi-thread safe. If a **DataSharePredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
### equalTo ### equalTo
equalTo(field: string, value: ValueType): DataSharePredicates equalTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is equal to the specified value. Sets a **DataSharePredicates** object to match the data that is equal to the specified value.
Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object. Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object.
...@@ -54,10 +54,11 @@ predicates.equalTo("NAME", "Rose") ...@@ -54,10 +54,11 @@ predicates.equalTo("NAME", "Rose")
notEqualTo(field: string, value: ValueType): DataSharePredicates notEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is not equal to the specified value. Sets a **DataSharePredicates** object to match the data that is not equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -88,6 +89,7 @@ Adds a left parenthesis to this **DataSharePredicates**. ...@@ -88,6 +89,7 @@ Adds a left parenthesis to this **DataSharePredicates**.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value** **Return value**
...@@ -116,6 +118,7 @@ Adds a right parenthesis to this **DataSharePredicates** object. ...@@ -116,6 +118,7 @@ Adds a right parenthesis to this **DataSharePredicates** object.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value** **Return value**
...@@ -144,6 +147,7 @@ Adds the OR condition to this **DataSharePredicates** object. ...@@ -144,6 +147,7 @@ Adds the OR condition to this **DataSharePredicates** object.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value** **Return value**
...@@ -190,10 +194,11 @@ predicates.equalTo("NAME", "lisi") ...@@ -190,10 +194,11 @@ predicates.equalTo("NAME", "lisi")
contains(field: string, value: string): DataSharePredicates contains(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that contains the specified value. Sets a **DataSharePredicates** object to match the data that contains the specified value.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -220,10 +225,11 @@ predicates.contains("NAME", "os") ...@@ -220,10 +225,11 @@ predicates.contains("NAME", "os")
beginsWith(field: string, value: string): DataSharePredicates beginsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that begins with the specified value. Sets a **DataSharePredicates** object to match the data that begins with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -250,10 +256,11 @@ predicates.beginsWith("NAME", "os") ...@@ -250,10 +256,11 @@ predicates.beginsWith("NAME", "os")
endsWith(field: string, value: string): DataSharePredicates endsWith(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that ends with the specified value. Sets a **DataSharePredicates** object to match the data that ends with the specified value.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -280,10 +287,11 @@ predicates.endsWith("NAME", "os") ...@@ -280,10 +287,11 @@ predicates.endsWith("NAME", "os")
isNull(field: string): DataSharePredicates isNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose value is null. Sets a **DataSharePredicates** object to match the data whose value is null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -309,10 +317,11 @@ predicates.isNull("NAME") ...@@ -309,10 +317,11 @@ predicates.isNull("NAME")
isNotNull(field: string): DataSharePredicates isNotNull(field: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose value is not null. Sets a **DataSharePredicates** object to match the data whose value is not null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -338,10 +347,11 @@ predicates.isNotNull("NAME") ...@@ -338,10 +347,11 @@ predicates.isNotNull("NAME")
like(field: string, value: string): DataSharePredicates like(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression. Sets a **DataSharePredicates** object to match the data that matches the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -368,10 +378,11 @@ predicates.like("NAME", "%os%") ...@@ -368,10 +378,11 @@ predicates.like("NAME", "%os%")
unlike(field: string, value: string): DataSharePredicates unlike(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that does not match the specified wildcard expression. Sets a **DataSharePredicates** object to match the data that does not match the specified wildcard expression.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -398,10 +409,11 @@ predicates.unlike("NAME", "%os%") ...@@ -398,10 +409,11 @@ predicates.unlike("NAME", "%os%")
glob(field: string, value: string): DataSharePredicates glob(field: string, value: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that matches the specified wildcard expression. Sets a **DataSharePredicates** object to match the data that matches the specified wildcard expression.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -428,10 +440,11 @@ predicates.glob("NAME", "?h*g") ...@@ -428,10 +440,11 @@ predicates.glob("NAME", "?h*g")
between(field: string, low: ValueType, high: ValueType): DataSharePredicates between(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is within the specified range, including the start and end values. Sets a **DataSharePredicates** object to match the data that is within the specified range, including the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -459,10 +472,11 @@ predicates.between("AGE", 10, 50) ...@@ -459,10 +472,11 @@ predicates.between("AGE", 10, 50)
notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is out of the specified range, excluding the start and end values. Sets a **DataSharePredicates** object to match the data that is out of the specified range, excluding the start and end values.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -490,10 +504,11 @@ predicates.notBetween("AGE", 10, 50) ...@@ -490,10 +504,11 @@ predicates.notBetween("AGE", 10, 50)
greaterThan(field: string, value: ValueType): DataSharePredicates greaterThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is greater than the specified value. Sets a **DataSharePredicates** object to match the data that is greater than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -520,10 +535,11 @@ predicates.greaterThan("AGE", 10) ...@@ -520,10 +535,11 @@ predicates.greaterThan("AGE", 10)
lessThan(field: string, value: ValueType): DataSharePredicates lessThan(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is less than the specified value. Sets a **DataSharePredicates** object to match the data that is less than the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -550,10 +566,11 @@ predicates.lessThan("AGE", 50) ...@@ -550,10 +566,11 @@ predicates.lessThan("AGE", 50)
greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is greater than or equal to the specified value. Sets a **DataSharePredicates** object to match the data that is greater than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -580,10 +597,11 @@ predicates.greaterThanOrEqualTo("AGE", 10) ...@@ -580,10 +597,11 @@ predicates.greaterThanOrEqualTo("AGE", 10)
lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is less than or equal to the specified value. Sets a **DataSharePredicates** object to match the data that is less than or equal to the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -672,6 +690,7 @@ Sets a **DataSharePredicates** object to filter out duplicate data records. ...@@ -672,6 +690,7 @@ Sets a **DataSharePredicates** object to filter out duplicate data records.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value** **Return value**
...@@ -725,6 +744,7 @@ Sets a **DataSharePredicates** object group the records according to the specifi ...@@ -725,6 +744,7 @@ Sets a **DataSharePredicates** object group the records according to the specifi
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -754,6 +774,7 @@ Sets a **DataSharePredicates** object to list data by the specified index. ...@@ -754,6 +774,7 @@ Sets a **DataSharePredicates** object to list data by the specified index.
Currently, only the RDB supports this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -779,7 +800,7 @@ predicates.indexedBy("SALARY_INDEX") ...@@ -779,7 +800,7 @@ predicates.indexedBy("SALARY_INDEX")
in(field: string, value: Array<ValueType>): DataSharePredicates in(field: string, value: Array<ValueType>): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is within the specified value. Sets a **DataSharePredicates** object to match the data that is within the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
...@@ -809,10 +830,11 @@ predicates.in("AGE", [18, 20]) ...@@ -809,10 +830,11 @@ predicates.in("AGE", [18, 20])
notIn(field: string, value: Array<ValueType>): DataSharePredicates notIn(field: string, value: Array<ValueType>): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data that is not in the specified value. Sets a **DataSharePredicates** object to match the data that is not in the specified value.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -839,10 +861,11 @@ predicates.notIn("NAME", ["Lisa", "Rose"]) ...@@ -839,10 +861,11 @@ predicates.notIn("NAME", ["Lisa", "Rose"])
prefixKey(prefix: string): DataSharePredicates prefixKey(prefix: string): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data with the specified key prefix. Sets a **DataSharePredicates** object to match the data with the specified key prefix.
Currently, only the KVDB supports this **DataSharePredicates** object. Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
...@@ -868,10 +891,11 @@ predicates.prefixKey("NAME") ...@@ -868,10 +891,11 @@ predicates.prefixKey("NAME")
inKeys(keys: Array<string>): DataSharePredicates inKeys(keys: Array<string>): DataSharePredicates
Sets a **DataSharePredicates** object to search for the data whose keys are within the given range. Sets a **DataSharePredicates** object to match the data whose keys are within the given range.
Currently, only the KVDB supports this **DataSharePredicates** object. Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
......
...@@ -23,10 +23,10 @@ Creates a distributed data object. ...@@ -23,10 +23,10 @@ Creates a distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| | context | Context | Yes| Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| source | object | Yes| Attributes of the distributed data object.| | source | object | Yes| Attributes of the distributed data object.|
**Return value** **Return value**
...@@ -75,9 +75,9 @@ Creates a random session ID. ...@@ -75,9 +75,9 @@ Creates a random session ID.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Session ID created.| | string | Session ID created.|
**Example** **Example**
...@@ -124,18 +124,18 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -124,18 +124,18 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sessionId | string | Yes| ID of a distributed data object on a trusted network.| | sessionId | string | Yes| ID of a distributed data object on a trusted network.|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the session ID is successfully set.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the session ID is successfully set.|
**Error codes** **Error codes**
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 15400001 | Failed to create the in-memory database.| | 15400001 | Create table failed.|
**Example** **Example**
...@@ -158,17 +158,17 @@ Exits all joined sessions. ...@@ -158,17 +158,17 @@ Exits all joined sessions.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.| | callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.|
**Error codes** **Error codes**
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 15400001 | Failed to create the in-memory database.| | 15400001 | Create table failed.|
**Example** **Example**
...@@ -195,9 +195,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -195,9 +195,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value** **Return value**
...@@ -209,9 +209,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -209,9 +209,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md).
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 15400001 | Failed to create the in-memory database.| | 15400001 | Create table failed.|
**Example** **Example**
...@@ -240,10 +240,10 @@ Subscribes to data changes of this distributed data object. ...@@ -240,10 +240,10 @@ Subscribes to data changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| | callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example** **Example**
...@@ -269,10 +269,10 @@ Unsubscribes from the data changes of this distributed data object. ...@@ -269,10 +269,10 @@ Unsubscribes from the data changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| | callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example** **Example**
...@@ -294,10 +294,10 @@ Subscribes to status changes of this distributed data object. ...@@ -294,10 +294,10 @@ Subscribes to status changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.| | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
**Example** **Example**
...@@ -318,10 +318,10 @@ Unsubscribes from the status change of this distributed data object. ...@@ -318,10 +318,10 @@ Unsubscribes from the status change of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.| | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
**Example** **Example**
...@@ -354,10 +354,10 @@ The saved data will be released in the following cases: ...@@ -354,10 +354,10 @@ The saved data will be released in the following cases:
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.| | deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
| callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| | callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example** **Example**
...@@ -394,15 +394,15 @@ The saved data will be released in the following cases: ...@@ -394,15 +394,15 @@ The saved data will be released in the following cases:
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. | | deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| | Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example** **Example**
...@@ -423,7 +423,7 @@ g_object.save("local").then((result) => { ...@@ -423,7 +423,7 @@ g_object.save("local").then((result) => {
revokeSave(callback: AsyncCallback&lt;RevokeSaveSuccessResponse&gt;): void revokeSave(callback: AsyncCallback&lt;RevokeSaveSuccessResponse&gt;): void
Revokes the saving operation of this distributed data object. This API uses an asynchronous callback to return the result. Revokes the data of this distributed data object saved. This API uses an asynchronous callback to return the result.
If the object is saved on the local device, the data saved on all trusted devices will be deleted. If the object is saved on the local device, the data saved on all trusted devices will be deleted.
If the object is stored on another device, the data on the local device will be deleted. If the object is stored on another device, the data on the local device will be deleted.
...@@ -432,9 +432,9 @@ If the object is stored on another device, the data on the local device will be ...@@ -432,9 +432,9 @@ If the object is stored on another device, the data on the local device will be
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.| | callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example** **Example**
...@@ -468,7 +468,7 @@ g_object.revokeSave((err, result) => { ...@@ -468,7 +468,7 @@ g_object.revokeSave((err, result) => {
revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt; revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt;
Revokes the saving operation of this distributed data object. This API uses a promise to return the result. Revokes the data of this distributed data object saved. This API uses a promise to return the result.
If the object is saved on the local device, the data saved on all trusted devices will be deleted. If the object is saved on the local device, the data saved on all trusted devices will be deleted.
If the object is stored on another device, the data on the local device will be deleted. If the object is stored on another device, the data on the local device will be deleted.
...@@ -477,9 +477,9 @@ If the object is stored on another device, the data on the local device will be ...@@ -477,9 +477,9 @@ If the object is stored on another device, the data on the local device will be
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.| | Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example** **Example**
...@@ -520,9 +520,9 @@ Creates a distributed data object. ...@@ -520,9 +520,9 @@ Creates a distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| source | object | Yes| Attributes of the distributed data object.| | source | object | Yes| Attributes of the distributed data object.|
**Return value** **Return value**
...@@ -558,15 +558,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -558,15 +558,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. | | boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
**Example** **Example**
...@@ -593,10 +593,10 @@ Subscribes to data changes of this distributed data object. ...@@ -593,10 +593,10 @@ Subscribes to data changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| | callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example** **Example**
...@@ -628,10 +628,10 @@ Unsubscribes from the data changes of this distributed data object. ...@@ -628,10 +628,10 @@ Unsubscribes from the data changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| | callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example** **Example**
...@@ -659,10 +659,10 @@ Subscribes to status changes of this distributed data object. ...@@ -659,10 +659,10 @@ Subscribes to status changes of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.| | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
**Example** **Example**
...@@ -689,8 +689,8 @@ Unsubscribes from the status change of this distributed data object. ...@@ -689,8 +689,8 @@ Unsubscribes from the status change of this distributed data object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.| | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
......
...@@ -185,7 +185,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod ...@@ -185,7 +185,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------| | -------- | ------------------------------|
| 15500010 | Failed to delete the preferences. | | 15500010 | Failed to delete preferences file. |
**Example** **Example**
...@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
try { try {
data_preferences.deletePreferences(context, 'mystore', function (err, val) { data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
data_preferences.deletePreferences(this.context, 'mystore', function (err, val) { data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -262,7 +262,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod ...@@ -262,7 +262,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod
| ID| Error Message | | ID| Error Message |
| -------- | ------------------------------| | -------- | ------------------------------|
| 15500010 | Failed to delete the preferences. | | 15500010 | Failed to delete preferences file. |
**Example** **Example**
...@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
try { try {
data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) { data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err, val) { data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message);
return; return;
......
...@@ -38,10 +38,11 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul ...@@ -38,10 +38,11 @@ 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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | ----------------------------------------------------------- |
| 14800010 | If failed delete database by invalid database name. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800011 | If failed open database by database corrupted. | | 14800011 | Failed to open database by database corrupted. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -64,7 +65,7 @@ const STORE_CONFIG = { ...@@ -64,7 +65,7 @@ const STORE_CONFIG = {
relationalStore.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) { relationalStore.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) {
store = rdbStore; store = rdbStore;
if (err) { if (err) {
console.error(`Get RdbStore failed, err: ${err}`); console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Get RdbStore successfully.`); console.info(`Get RdbStore successfully.`);
...@@ -87,7 +88,7 @@ class EntryAbility extends UIAbility { ...@@ -87,7 +88,7 @@ class EntryAbility extends UIAbility {
relationalStore.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) { relationalStore.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) {
store = rdbStore; store = rdbStore;
if (err) { if (err) {
console.error(`Get RdbStore failed, err: ${err}`); console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Get RdbStore successfully.`); console.info(`Get RdbStore successfully.`);
...@@ -121,10 +122,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ...@@ -121,10 +122,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | ----------------------------------------------------------- |
| 14800010 | If failed delete database by invalid database name. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800011 | If failed open database by database corrupted. | | 14800011 | Failed to open database by database corrupted. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -148,7 +150,7 @@ promise.then(async (rdbStore) => { ...@@ -148,7 +150,7 @@ promise.then(async (rdbStore) => {
store = rdbStore; store = rdbStore;
console.info(`Get RdbStore successfully.`); console.info(`Get RdbStore successfully.`);
}).catch((err) => { }).catch((err) => {
console.error(`Get RdbStore failed, err: ${err}`); console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -170,7 +172,7 @@ class EntryAbility extends UIAbility { ...@@ -170,7 +172,7 @@ class EntryAbility extends UIAbility {
store = rdbStore; store = rdbStore;
console.info(`Get RdbStore successfully.`) console.info(`Get RdbStore successfully.`)
}).catch((err) => { }).catch((err) => {
console.error(`Get RdbStore failed, err: ${err}`); console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
}) })
} }
} }
...@@ -196,9 +198,10 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul ...@@ -196,9 +198,10 @@ Deletes 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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | ----------------------------------------------------------- |
| 14800010 | If failed delete database by invalid database name. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -212,7 +215,7 @@ let context = featureAbility.getContext() ...@@ -212,7 +215,7 @@ let context = featureAbility.getContext()
relationalStore.deleteRdbStore(context, "RdbTest.db", function (err) { relationalStore.deleteRdbStore(context, "RdbTest.db", function (err) {
if (err) { if (err) {
console.error(`Delete RdbStore failed, err: ${err}`); console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Delete RdbStore successfully.`); console.info(`Delete RdbStore successfully.`);
...@@ -228,7 +231,7 @@ class EntryAbility extends UIAbility { ...@@ -228,7 +231,7 @@ class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage){
relationalStore.deleteRdbStore(this.context, "RdbTest.db", function (err) { relationalStore.deleteRdbStore(this.context, "RdbTest.db", function (err) {
if (err) { if (err) {
console.error(`Delete RdbStore failed, err: ${err}`); console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Delete RdbStore successfully.`); console.info(`Delete RdbStore successfully.`);
...@@ -262,9 +265,10 @@ Deletes an RDB store. This API uses a promise to return the result. ...@@ -262,9 +265,10 @@ Deletes an RDB store. This API uses a promise to return the result.
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | ----------------------------------------------------------- |
| 14800010 | If failed delete database by invalid database name. | | 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -280,7 +284,7 @@ let promise = relationalStore.deleteRdbStore(context, "RdbTest.db"); ...@@ -280,7 +284,7 @@ let promise = relationalStore.deleteRdbStore(context, "RdbTest.db");
promise.then(()=>{ promise.then(()=>{
console.info(`Delete RdbStore successfully.`); console.info(`Delete RdbStore successfully.`);
}).catch((err) => { }).catch((err) => {
console.error(`Delete RdbStore failed, err: ${err}`); console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -295,7 +299,7 @@ class EntryAbility extends UIAbility { ...@@ -295,7 +299,7 @@ class EntryAbility extends UIAbility {
promise.then(()=>{ promise.then(()=>{
console.info(`Delete RdbStore successfully.`); console.info(`Delete RdbStore successfully.`);
}).catch((err) => { }).catch((err) => {
console.error(`Delete RdbStore failed, err: ${err}`); console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
}) })
} }
} }
...@@ -311,7 +315,7 @@ Defines the RDB store configuration. ...@@ -311,7 +315,7 @@ Defines the RDB store configuration.
| ------------- | ------------- | ---- | --------------------------------------------------------- | | ------------- | ------------- | ---- | --------------------------------------------------------- |
| name | string | Yes | Database file name. | | name | string | Yes | Database file name. |
| securityLevel | [SecurityLevel](#securitylevel) | Yes | Security level of the RDB store. | | securityLevel | [SecurityLevel](#securitylevel) | Yes | Security level of the RDB store. |
| encrypt | boolean | No | Whether to encrypt the RDB store.<br> The value **true** means to encrypt the RDB store;<br> the value **false** means the opposite.| | encrypt | boolean | No | Whether to encrypt the RDB store.<br> The value **true** means to encrypt the RDB store;<br> the value **false** (default) means the opposite.|
## SecurityLevel ## SecurityLevel
...@@ -319,7 +323,7 @@ Enumerates the RDB store security levels. ...@@ -319,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).
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
...@@ -344,7 +348,7 @@ Defines the data types allowed. ...@@ -344,7 +348,7 @@ Defines the data types allowed.
## ValuesBucket ## ValuesBucket
Defines the types of the key and value in a KV pair. Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
...@@ -374,6 +378,7 @@ Defines the subscription type. ...@@ -374,6 +378,7 @@ Defines the subscription type.
| Name | Value | Description | | Name | Value | Description |
| --------------------- | ---- | ------------------ | | --------------------- | ---- | ------------------ |
| SUBSCRIBE_TYPE_REMOTE | 0 | Subscribe to remote data changes.| | SUBSCRIBE_TYPE_REMOTE | 0 | Subscribe to remote data changes.|
| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1 | Subscribe to cloud data changes.|
## ConflictResolution<sup>10+</sup> ## ConflictResolution<sup>10+</sup>
...@@ -392,7 +397,7 @@ Defines the resolution to use when **insert()** and **update()** conflict. ...@@ -392,7 +397,7 @@ Defines the resolution to use when **insert()** and **update()** conflict.
## RdbPredicates ## RdbPredicates
Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. 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.
### constructor ### constructor
...@@ -1289,9 +1294,10 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re ...@@ -1289,9 +1294,10 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1304,7 +1310,7 @@ const valueBucket = { ...@@ -1304,7 +1310,7 @@ const valueBucket = {
}; };
store.insert("EMPLOYEE", valueBucket, function (err, rowId) { store.insert("EMPLOYEE", valueBucket, function (err, rowId) {
if (err) { if (err) {
console.error(`Insert is failed, err: ${err}`); console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Insert is successful, rowId = ${rowId}`); console.info(`Insert is successful, rowId = ${rowId}`);
...@@ -1332,9 +1338,10 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re ...@@ -1332,9 +1338,10 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1347,7 +1354,7 @@ const valueBucket = { ...@@ -1347,7 +1354,7 @@ const valueBucket = {
}; };
store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rowId) { store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rowId) {
if (err) { if (err) {
console.error(`Insert is failed, err: ${err}`); console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Insert is successful, rowId = ${rowId}`); console.info(`Insert is successful, rowId = ${rowId}`);
...@@ -1379,9 +1386,10 @@ Inserts a row of data into a table. This API uses a promise to return the result ...@@ -1379,9 +1386,10 @@ Inserts a row of data into a table. This API uses a promise to return the result
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1396,7 +1404,7 @@ let promise = store.insert("EMPLOYEE", valueBucket); ...@@ -1396,7 +1404,7 @@ let promise = store.insert("EMPLOYEE", valueBucket);
promise.then((rowId) => { promise.then((rowId) => {
console.info(`Insert is successful, rowId = ${rowId}`); console.info(`Insert is successful, rowId = ${rowId}`);
}).catch((err) => { }).catch((err) => {
console.error(`Insert is failed, err: ${err}`); console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1426,9 +1434,10 @@ Inserts a row of data into a table. This API uses a promise to return the result ...@@ -1426,9 +1434,10 @@ Inserts a row of data into a table. This API uses a promise to return the result
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1443,7 +1452,7 @@ let promise = store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictReso ...@@ -1443,7 +1452,7 @@ let promise = store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictReso
promise.then((rowId) => { promise.then((rowId) => {
console.info(`Insert is successful, rowId = ${rowId}`); console.info(`Insert is successful, rowId = ${rowId}`);
}).catch((err) => { }).catch((err) => {
console.error(`Insert is failed, err: ${err}`); console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1467,9 +1476,10 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur ...@@ -1467,9 +1476,10 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1496,7 +1506,7 @@ const valueBucket3 = { ...@@ -1496,7 +1506,7 @@ const valueBucket3 = {
let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
store.batchInsert("EMPLOYEE", valueBuckets, function(err, insertNum) { store.batchInsert("EMPLOYEE", valueBuckets, function(err, insertNum) {
if (err) { if (err) {
console.error(`batchInsert is failed, err: ${err}`); console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
...@@ -1528,9 +1538,10 @@ Batch inserts data into a table. This API uses a promise to return the result. ...@@ -1528,9 +1538,10 @@ Batch inserts data into a table. This API uses a promise to return the result.
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1559,7 +1570,7 @@ let promise = store.batchInsert("EMPLOYEE", valueBuckets); ...@@ -1559,7 +1570,7 @@ let promise = store.batchInsert("EMPLOYEE", valueBuckets);
promise.then((insertNum) => { promise.then((insertNum) => {
console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
}).catch((err) => { }).catch((err) => {
console.error(`batchInsert is failed, err: ${err}`); console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1583,9 +1594,10 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T ...@@ -1583,9 +1594,10 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1600,7 +1612,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -1600,7 +1612,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.update(valueBucket, predicates, function (err, rows) { store.update(valueBucket, predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
...@@ -1628,9 +1640,10 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T ...@@ -1628,9 +1640,10 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1645,7 +1658,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -1645,7 +1658,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rows) { store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rows) {
if (err) { if (err) {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
...@@ -1677,9 +1690,10 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr ...@@ -1677,9 +1690,10 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1696,7 +1710,7 @@ let promise = store.update(valueBucket, predicates); ...@@ -1696,7 +1710,7 @@ let promise = store.update(valueBucket, predicates);
promise.then(async (rows) => { promise.then(async (rows) => {
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1726,9 +1740,10 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr ...@@ -1726,9 +1740,10 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1745,7 +1760,7 @@ let promise = store.update(valueBucket, predicates, relationalStore.ConflictReso ...@@ -1745,7 +1760,7 @@ let promise = store.update(valueBucket, predicates, relationalStore.ConflictReso
promise.then(async (rows) => { promise.then(async (rows) => {
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1757,6 +1772,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use ...@@ -1757,6 +1772,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -1772,9 +1789,10 @@ Updates data based on the specified **DataSharePredicates** object. This API use ...@@ -1772,9 +1789,10 @@ Updates data based on the specified **DataSharePredicates** object. This API use
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1790,7 +1808,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); ...@@ -1790,7 +1808,7 @@ let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) { store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
...@@ -1805,6 +1823,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use ...@@ -1805,6 +1823,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -1825,9 +1845,10 @@ Updates data based on the specified **DataSharePredicates** object. This API use ...@@ -1825,9 +1845,10 @@ Updates data based on the specified **DataSharePredicates** object. This API use
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1845,7 +1866,7 @@ let promise = store.update("EMPLOYEE", valueBucket, predicates); ...@@ -1845,7 +1866,7 @@ let promise = store.update("EMPLOYEE", valueBucket, predicates);
promise.then(async (rows) => { promise.then(async (rows) => {
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Updated failed, err: ${err}`); console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1868,9 +1889,10 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. ...@@ -1868,9 +1889,10 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object.
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1879,7 +1901,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -1879,7 +1901,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.delete(predicates, function (err, rows) { store.delete(predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Delete failed, err: ${err}`); console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Delete rows: ${rows}`); console.info(`Delete rows: ${rows}`);
...@@ -1910,9 +1932,10 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. ...@@ -1910,9 +1932,10 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object.
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1923,7 +1946,7 @@ let promise = store.delete(predicates); ...@@ -1923,7 +1946,7 @@ let promise = store.delete(predicates);
promise.then((rows) => { promise.then((rows) => {
console.info(`Delete rows: ${rows}`); console.info(`Delete rows: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Delete failed, err: ${err}`); console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -1935,6 +1958,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1935,6 +1958,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -1949,9 +1974,10 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1949,9 +1974,10 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -1961,7 +1987,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); ...@@ -1961,7 +1987,7 @@ let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.delete("EMPLOYEE", predicates, function (err, rows) { store.delete("EMPLOYEE", predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Delete failed, err: ${err}`); console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Delete rows: ${rows}`); console.info(`Delete rows: ${rows}`);
...@@ -1976,6 +2002,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1976,6 +2002,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -1995,9 +2023,10 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1995,9 +2023,10 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2009,7 +2038,7 @@ let promise = store.delete("EMPLOYEE", predicates); ...@@ -2009,7 +2038,7 @@ let promise = store.delete("EMPLOYEE", predicates);
promise.then((rows) => { promise.then((rows) => {
console.info(`Delete rows: ${rows}`); console.info(`Delete rows: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Delete failed, err: ${err}`); console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2029,6 +2058,14 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -2029,6 +2058,14 @@ Queries data from the RDB store based on specified conditions. This API uses an
| columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. |
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2036,7 +2073,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -2036,7 +2073,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Rose"); predicates.equalTo("NAME", "Rose");
store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) {
if (err) { if (err) {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
...@@ -2059,6 +2096,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -2059,6 +2096,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. | | predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. |
| columns | Array&lt;string&gt; | No | Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | No | Columns to query. If this parameter is not specified, the query applies to all columns.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -2075,7 +2120,7 @@ promise.then((resultSet) => { ...@@ -2075,7 +2120,7 @@ promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`); console.info(`ResultSet column count: ${resultSet.columnCount}`);
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2087,6 +2132,8 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -2087,6 +2132,8 @@ Queries data from the RDB store based on specified conditions. This API uses an
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -2098,6 +2145,14 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -2098,6 +2145,14 @@ Queries data from the RDB store based on specified conditions. This API uses an
| columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. |
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2106,7 +2161,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); ...@@ -2106,7 +2161,7 @@ let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo("NAME", "Rose"); predicates.equalTo("NAME", "Rose");
store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) {
if (err) { if (err) {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
...@@ -2122,6 +2177,8 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -2122,6 +2177,8 @@ Queries data from the RDB store based on specified conditions. This API uses a p
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Model restriction**: This API can be used only in the stage model.
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
...@@ -2138,6 +2195,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -2138,6 +2195,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p
| ------------------------------------------------------- | -------------------------------------------------- | | ------------------------------------------------------- | -------------------------------------------------- |
| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2149,7 +2214,7 @@ promise.then((resultSet) => { ...@@ -2149,7 +2214,7 @@ promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`); console.info(`ResultSet column count: ${resultSet.columnCount}`);
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2175,6 +2240,14 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -2175,6 +2240,14 @@ Queries data from the RDB store of a remote device based on specified conditions
| columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. |
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2197,7 +2270,7 @@ predicates.greaterThan("id", 0); ...@@ -2197,7 +2270,7 @@ predicates.greaterThan("id", 0);
store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"],
function(err, resultSet) { function(err, resultSet) {
if (err) { if (err) {
console.error(`Failed to remoteQuery, err: ${err}`); console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
...@@ -2233,6 +2306,14 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -2233,6 +2306,14 @@ Queries data from the RDB store of a remote device based on specified conditions
| ------------------------------------------------------------ | -------------------------------------------------- | | ------------------------------------------------------------ | -------------------------------------------------- |
| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2257,7 +2338,7 @@ promise.then((resultSet) => { ...@@ -2257,7 +2338,7 @@ promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`); console.info(`ResultSet column count: ${resultSet.columnCount}`);
}).catch((err) => { }).catch((err) => {
console.error(`Failed to remoteQuery, err: ${err}`); console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2277,12 +2358,20 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca ...@@ -2277,12 +2358,20 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.| | bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.|
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned. | | callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) {
if (err) { if (err) {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
...@@ -2311,6 +2400,14 @@ Queries data using the specified SQL statement. This API uses a promise to retur ...@@ -2311,6 +2400,14 @@ Queries data using the specified SQL statement. This API uses a promise to retur
| ------------------------------------------------------- | -------------------------------------------------- | | ------------------------------------------------------- | -------------------------------------------------- |
| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2319,7 +2416,7 @@ promise.then((resultSet) => { ...@@ -2319,7 +2416,7 @@ promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`); console.info(`ResultSet column count: ${resultSet.columnCount}`);
}).catch((err) => { }).catch((err) => {
console.error(`Query failed, err: ${err}`); console.error(`Query failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2343,9 +2440,10 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -2343,9 +2440,10 @@ Executes an SQL statement that contains specified arguments but returns no value
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2353,7 +2451,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -2353,7 +2451,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?" const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
store.executeSql(SQL_DELETE_TABLE, ['zhangsan'], function(err) { store.executeSql(SQL_DELETE_TABLE, ['zhangsan'], function(err) {
if (err) { if (err) {
console.error(`ExecuteSql failed, err: ${err}`); console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Delete table done.`); console.info(`Delete table done.`);
...@@ -2385,9 +2483,10 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -2385,9 +2483,10 @@ Executes an SQL statement that contains specified arguments but returns no value
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2397,7 +2496,7 @@ let promise = store.executeSql(SQL_DELETE_TABLE); ...@@ -2397,7 +2496,7 @@ let promise = store.executeSql(SQL_DELETE_TABLE);
promise.then(() => { promise.then(() => {
console.info(`Delete table done.`); console.info(`Delete table done.`);
}).catch((err) => { }).catch((err) => {
console.error(`ExecuteSql failed, err: ${err}`); console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2413,9 +2512,10 @@ Starts the transaction before executing an SQL statement. ...@@ -2413,9 +2512,10 @@ Starts the transaction before executing an SQL statement.
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).
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ----------------------- | | ------------ | -------------------------------------------- |
| 14800047 | The WAL file size exceeds the default limit.| | 14800047 | The WAL file size exceeds the default limit. |
| 14800000 | Inner error. |
**Example** **Example**
...@@ -2428,7 +2528,7 @@ const STORE_CONFIG = { ...@@ -2428,7 +2528,7 @@ const STORE_CONFIG = {
}; };
relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) {
if (err) { if (err) {
console.error(`GetRdbStore failed, err: ${err}`); console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
store.beginTransaction(); store.beginTransaction();
...@@ -2462,7 +2562,7 @@ const STORE_CONFIG = { ...@@ -2462,7 +2562,7 @@ const STORE_CONFIG = {
}; };
relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) {
if (err) { if (err) {
console.error(`GetRdbStore failed, err: ${err}`); console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
store.beginTransaction(); store.beginTransaction();
...@@ -2496,7 +2596,7 @@ const STORE_CONFIG = { ...@@ -2496,7 +2596,7 @@ const STORE_CONFIG = {
}; };
relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) {
if (err) { if (err) {
console.error(`GetRdbStore failed, err: ${err}`); console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
try { try {
...@@ -2511,7 +2611,7 @@ relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { ...@@ -2511,7 +2611,7 @@ relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) {
await store.insert("test", valueBucket); await store.insert("test", valueBucket);
store.commit(); store.commit();
} catch (err) { } catch (err) {
console.error(`Transaction failed, err: ${err}`); console.error(`Transaction failed, code is ${err.code},message is ${err.message}`);
store.rollBack(); store.rollBack();
} }
}) })
...@@ -2532,12 +2632,20 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu ...@@ -2532,12 +2632,20 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu
| destName | string | Yes | Name of the RDB store backup file.| | destName | string | Yes | Name of the RDB store backup file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
store.backup("dbBackup.db", function(err) { store.backup("dbBackup.db", function(err) {
if (err) { if (err) {
console.error(`Backup failed, err: ${err}`); console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Backup success.`); console.info(`Backup success.`);
...@@ -2564,6 +2672,14 @@ Backs up an RDB store. This API uses a promise to return the result. ...@@ -2564,6 +2672,14 @@ Backs up an RDB store. This API uses a promise to return the result.
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2571,7 +2687,7 @@ let promiseBackup = store.backup("dbBackup.db"); ...@@ -2571,7 +2687,7 @@ let promiseBackup = store.backup("dbBackup.db");
promiseBackup.then(()=>{ promiseBackup.then(()=>{
console.info(`Backup success.`); console.info(`Backup success.`);
}).catch((err)=>{ }).catch((err)=>{
console.error(`Backup failed, err: ${err}`); console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2590,12 +2706,20 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback ...@@ -2590,12 +2706,20 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback
| srcName | string | Yes | Name of the RDB store backup file.| | srcName | string | Yes | Name of the RDB store backup file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
store.restore("dbBackup.db", function(err) { store.restore("dbBackup.db", function(err) {
if (err) { if (err) {
console.error(`Restore failed, err: ${err}`); console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Restore success.`); console.info(`Restore success.`);
...@@ -2622,6 +2746,14 @@ Restores an RDB store from a backup file. This API uses a promise to return the ...@@ -2622,6 +2746,14 @@ Restores an RDB store from a backup file. This API uses a promise to return the
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2629,7 +2761,7 @@ let promiseRestore = store.restore("dbBackup.db"); ...@@ -2629,7 +2761,7 @@ let promiseRestore = store.restore("dbBackup.db");
promiseRestore.then(()=>{ promiseRestore.then(()=>{
console.info(`Restore success.`); console.info(`Restore success.`);
}).catch((err)=>{ }).catch((err)=>{
console.error(`Restore failed, err: ${err}`); console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2650,12 +2782,20 @@ Sets distributed tables. This API uses an asynchronous callback to return the re ...@@ -2650,12 +2782,20 @@ Sets distributed tables. This API uses an asynchronous callback to return the re
| tables | Array&lt;string&gt; | Yes | Names of the distributed tables to set.| | tables | Array&lt;string&gt; | Yes | Names of the distributed tables to set.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
store.setDistributedTables(["EMPLOYEE"], function (err) { store.setDistributedTables(["EMPLOYEE"], function (err) {
if (err) { if (err) {
console.error(`SetDistributedTables failed, err: ${err}`); console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`SetDistributedTables successfully.`); console.info(`SetDistributedTables successfully.`);
...@@ -2684,6 +2824,14 @@ Sets distributed tables. This API uses a promise to return the result. ...@@ -2684,6 +2824,14 @@ Sets distributed tables. This API uses a promise to return the result.
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2691,7 +2839,7 @@ let promise = store.setDistributedTables(["EMPLOYEE"]); ...@@ -2691,7 +2839,7 @@ let promise = store.setDistributedTables(["EMPLOYEE"]);
promise.then(() => { promise.then(() => {
console.info(`SetDistributedTables successfully.`); console.info(`SetDistributedTables successfully.`);
}).catch((err) => { }).catch((err) => {
console.error(`SetDistributedTables failed, err: ${err}`); console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2717,6 +2865,14 @@ Obtains the distributed table name of a remote device based on the local table n ...@@ -2717,6 +2865,14 @@ Obtains the distributed table name of a remote device based on the local table n
| table | string | Yes | Local table name of the remote device. | | table | string | Yes | Local table name of the remote device. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2736,7 +2892,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) ...@@ -2736,7 +2892,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) {
if (err) { if (err) {
console.error(`ObtainDistributedTableName failed, err: ${err}`); console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
...@@ -2770,6 +2926,14 @@ Obtains the distributed table name of a remote device based on the local table n ...@@ -2770,6 +2926,14 @@ Obtains the distributed table name of a remote device based on the local table n
| --------------------- | ----------------------------------------------------- | | --------------------- | ----------------------------------------------------- |
| Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2791,7 +2955,7 @@ let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE"); ...@@ -2791,7 +2955,7 @@ let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE");
promise.then((tableName) => { promise.then((tableName) => {
console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
}).catch((err) => { }).catch((err) => {
console.error(`ObtainDistributedTableName failed, err: ${err}`); console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2813,6 +2977,14 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -2813,6 +2977,14 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
| 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&lt;Array&lt;[string, number]&gt;&gt; | 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. | | callback | AsyncCallback&lt;Array&lt;[string, number]&gt;&gt; | 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. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2836,7 +3008,7 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); ...@@ -2836,7 +3008,7 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.inDevices(deviceIds); predicates.inDevices(deviceIds);
store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
if (err) { if (err) {
console.error(`Sync failed, err: ${err}`); console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
return; return;
} }
console.info(`Sync done.`); console.info(`Sync done.`);
...@@ -2869,6 +3041,14 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -2869,6 +3041,14 @@ Synchronizes data between devices. This API uses a promise to return the result.
| -------------------------------------------- | ------------------------------------------------------------ | | -------------------------------------------- | ------------------------------------------------------------ |
| Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to send the synchronization result. <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. | | Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to send the synchronization result. <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. |
**Error codes**
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
| **ID**| **Error Message** |
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**Example** **Example**
```js ```js
...@@ -2897,7 +3077,7 @@ promise.then((result) =>{ ...@@ -2897,7 +3077,7 @@ promise.then((result) =>{
console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
} }
}).catch((err) => { }).catch((err) => {
console.error(`Sync failed, err: ${err}`); console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
}) })
``` ```
...@@ -2915,7 +3095,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes ...@@ -2915,7 +3095,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes
| -------- | ----------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------- | ---- | ------------------------------------------- |
| 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&lt;Array&lt;string&gt;&gt; | Yes | Callback invoked to return the data change event. | | observer | Callback&lt;Array&lt;string&gt;&gt; | 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**
...@@ -2928,7 +3108,7 @@ function storeObserver(devices) { ...@@ -2928,7 +3108,7 @@ function storeObserver(devices) {
try { try {
store.on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); store.on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
} catch (err) { } catch (err) {
console.error(`Register observer failed, err: ${err}`); console.error(`Register observer failed, code is ${err.code},message is ${err.message}`);
} }
``` ```
...@@ -2944,9 +3124,9 @@ Unregisters the observer of the specified type from the RDB store. This API uses ...@@ -2944,9 +3124,9 @@ Unregisters the observer of the specified type from the RDB store. This API uses
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | ------------------------------------------ | | -------- | ---------------------------------- | ---- | ------------------------------------------ |
| event | string | Yes | Event type. 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&lt;Array&lt;string&gt;&gt; | Yes | Callback for the data change event. | | observer | Callback&lt;Array&lt;string&gt;&gt; | 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**
...@@ -2959,7 +3139,7 @@ function storeObserver(devices) { ...@@ -2959,7 +3139,7 @@ function storeObserver(devices) {
try { try {
store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
} catch (err) { } catch (err) {
console.error(`Unregister observer failed, err: ${err}`); console.error(`Unregister observer failed, code is ${err.code},message is ${err.message}`);
} }
``` ```
...@@ -3099,7 +3279,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3099,7 +3279,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3110,7 +3290,7 @@ promise.then((resultSet) => { ...@@ -3110,7 +3290,7 @@ promise.then((resultSet) => {
resultSet.goTo(1); resultSet.goTo(1);
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3140,7 +3320,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3140,7 +3320,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3151,7 +3331,7 @@ promise.then((resultSet) => { ...@@ -3151,7 +3331,7 @@ promise.then((resultSet) => {
resultSet.goToRow(5); resultSet.goToRow(5);
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3176,7 +3356,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3176,7 +3356,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3187,7 +3367,7 @@ promise.then((resultSet) => { ...@@ -3187,7 +3367,7 @@ promise.then((resultSet) => {
resultSet.goToFirstRow(); resultSet.goToFirstRow();
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3211,7 +3391,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3211,7 +3391,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3222,7 +3402,7 @@ promise.then((resultSet) => { ...@@ -3222,7 +3402,7 @@ promise.then((resultSet) => {
resultSet.goToLastRow(); resultSet.goToLastRow();
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3246,7 +3426,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3246,7 +3426,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3257,7 +3437,7 @@ promise.then((resultSet) => { ...@@ -3257,7 +3437,7 @@ promise.then((resultSet) => {
resultSet.goToNextRow(); resultSet.goToNextRow();
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3281,7 +3461,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3281,7 +3461,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
**Example** **Example**
...@@ -3292,7 +3472,7 @@ promise.then((resultSet) => { ...@@ -3292,7 +3472,7 @@ promise.then((resultSet) => {
resultSet.goToPreviousRow(); resultSet.goToPreviousRow();
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`query failed, err: ${err}`); console.error(`query failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3316,6 +3496,14 @@ Obtains the value in the form of a byte array based on the specified column and ...@@ -3316,6 +3496,14 @@ Obtains the value in the form of a byte array based on the specified column and
| ---------- | -------------------------------- | | ---------- | -------------------------------- |
| Uint8Array | Value obtained.| | Uint8Array | Value 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** **Example**
```js ```js
...@@ -3342,6 +3530,14 @@ Obtains the value in the form of a string based on the specified column and the ...@@ -3342,6 +3530,14 @@ Obtains the value in the form of a string based on the specified column and the
| ------ | ---------------------------- | | ------ | ---------------------------- |
| string | String obtained.| | string | String 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** **Example**
```js ```js
...@@ -3366,7 +3562,15 @@ Obtains the value of the Long type based on the specified column and the current ...@@ -3366,7 +3562,15 @@ Obtains the value of the Long type based on the specified column and the current
| Type | Description | | Type | Description |
| ------ | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ |
| 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**
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** **Example**
...@@ -3394,6 +3598,14 @@ Obtains the value of the double type based on the specified column and the curre ...@@ -3394,6 +3598,14 @@ Obtains the value of the double type based on the specified column and the curre
| ------ | ---------------------------- | | ------ | ---------------------------- |
| number | Value obtained.| | number | Value 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** **Example**
```js ```js
...@@ -3450,7 +3662,7 @@ let promiseClose = store.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", ...@@ -3450,7 +3662,7 @@ let promiseClose = store.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY",
promiseClose.then((resultSet) => { promiseClose.then((resultSet) => {
resultSet.close(); resultSet.close();
}).catch((err) => { }).catch((err) => {
console.error(`resultset close failed, err: ${err}`); console.error(`resultset close failed, code is ${err.code},message is ${err.message}`);
}); });
``` ```
...@@ -3460,6 +3672,4 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode ...@@ -3460,6 +3672,4 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode
| **ID**| **Error Message** | | **ID**| **Error Message** |
| ------------ | ------------------------------------------------------------ | | ------------ | ------------------------------------------------------------ |
| 14800012 | The result set is empty or the specified location is invalid. | | 14800012 | The result set is empty or the specified location is invalid. |
<!--no_check-->
# @ohos.data.ValuesBucket (Value Bucket) # @ohos.data.ValuesBucket (Data Set)
The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database. The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
...@@ -6,7 +6,6 @@ The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to ...@@ -6,7 +6,6 @@ The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> >
> The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -30,7 +29,7 @@ Enumerates the value types allowed by the database. ...@@ -30,7 +29,7 @@ Enumerates the value types allowed by the database.
## ValuesBucket ## ValuesBucket
Defines the types of the key and value in a KV pair. Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......
...@@ -4,11 +4,29 @@ ...@@ -4,11 +4,29 @@
> >
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 14800000 Internal Error
**Error Message**
Inner error.
**Description**
An error occurs at the underlying database.
**Possible Causes**
Invalid SQL statement is passed in.
**Solution**
Determine the cause of the error based on the log information.
## 14800010 Invalid RDB Name ## 14800010 Invalid RDB Name
**Error Message** **Error Message**
Invalid database name. Failed to open or delete database by invalid database path.
**Description** **Description**
...@@ -16,17 +34,17 @@ The RDB store name is invalid. ...@@ -16,17 +34,17 @@ The RDB store name is invalid.
**Possible Causes** **Possible Causes**
The RDB store name is empty or exceeds 1024 bytes. The RDB store path is invalid.
**Solution** **Solution**
Check that the RDB store name is not empty and does not exceed 1024 bytes. Check the RDB store path.
## 14800011 Database File Corrupted ## 14800011 Database File Corrupted
**Error Message** **Error Message**
Database corrupted. Failed to open database by database corrupted.
**Description** **Description**
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
**Error Message** **Error Message**
The dataShareHelper is not initialized successfully. The DataShareHelper is not initialized successfully.
**Description** **Description**
...@@ -23,3 +23,40 @@ The **DataShareHelper** class fails to be created. ...@@ -23,3 +23,40 @@ The **DataShareHelper** class fails to be created.
1. Obtain the correct URI. 1. Obtain the correct URI.
2. Check that the context of the stage model is used. 2. Check that the context of the stage model is used.
## 15700011 Failed to Add or Delete a Template
**Error Message**
The uri is not exist.
**Description**
This error code is returned when a template fails to be added or deleted.
**Possible Causes**
1. The input parameter **uri** of **addTemplate()** is incorrect.
2. The input parameter **uri** of **delTemplate()** is incorrect.
**Solution**
Obtain the correct URI.
## 15700012 Data Area Not Exist
**Error Message**
The data area is not exist.
**Description**
This error code is returned when a data update fails.
**Possible Causes**
The input parameter **bundleName** of **publish()** is incorrect.
**Solution**
Obtain the correct **bundleName** value from the DataShare server provider.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## 15500010 Failed to Delete the User Preference Persistence File ## 15500010 Failed to Delete the User Preference Persistence File
**Error Message** **Error Message**
Failed to delete preferences. Failed to delete preferences file.
**Description** **Description**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册