The **distributedKVStore** module implements collaboration between databases for different devices that forms a Super Device. The APIs provided by this module can be used to save data to a distributed key-value (KV) store and perform operations, such as adding, deleting, modifying, querying, and synchronizing data in distributed KV stores.
The **distributedKVStore** module implements collaboration between databases for different devices that forms a Super Device. You can use the APIs provided by this module to save application data to a distributed key-value (KV) store and perform operations, such as adding, deleting, modifying, querying, and synchronizing data in distributed KV stores.
The **distributedKVStore** module provides the following functions:
The **distributedKVStore** module provides the following functions:
-[KVManager](#kvmanager): provides a **KVManager** instance to obtain KV store information.
-[KVManager](#kvmanager): provides a **KVManager** instance to obtain KV store information.
-[KVStoreResultSet](#kvstoreresultset): provides APIs for obtaining KV store result sets.
-[KVStoreResultSet](#kvstoreresultset): provides APIs for accessing the results obtained from a KV store.
-[Query](#query): provides APIs for setting predicates and querying data using predicates.
-[Query](#query): provides APIs for setting predicates for data query.
-[SingleKVStore](#singlekvstore): provides APIs for querying data in single KV stores and synchronizing data. The single KV stores manage data without distinguishing devices.
-[SingleKVStore](#singlekvstore): provides APIs for querying and synchronizing data in single KV stores. The single KV stores manage data without distinguishing devices.
-[DeviceKVStore](#devicekvstore): provides APIs for querying in device KV stores and synchronizing data. This class inherits from [SingleKVStore](#singlekvstore). The device KV stores manage data by device.
-[DeviceKVStore](#devicekvstore): provides APIs for querying and synchronizing data in device KV stores. This class inherits from [SingleKVStore](#singlekvstore). The device KV stores manage data by device.
> **NOTE**
> **NOTE**
>
>
> 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.
> <br>All the APIs that need to obtain **deviceId** in this module are available only to system applications.
## Modules to Import
## Modules to Import
...
@@ -22,13 +23,13 @@ import distributedKVStore from '@ohos.data.distributedKVStore';
...
@@ -22,13 +23,13 @@ import distributedKVStore from '@ohos.data.distributedKVStore';
## KVManagerConfig
## KVManagerConfig
Provides the **KVManager** instance configuration, including the bundle name of the invoker and the application context.
Defines the **KVManager** instance configuration, including the bundle name of the invoker and the application context.
| 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).<br>Since API version 10, the type of **context** is [BaseContext](js-apis-inner-application-baseContext.md).|
| bundleName | string | Yes | Bundle name. |
| bundleName | string | Yes | Bundle name. |
## Constants
## Constants
...
@@ -39,16 +40,16 @@ Provides constants of the distributed KV store.
...
@@ -39,16 +40,16 @@ Provides constants of the distributed KV store.
| DEVICE_COLLABORATION | Device KV store.<br> The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
| DEVICE_COLLABORATION | Device KV store.<br>The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| SINGLE_VERSION | Single KV store.<br> The single KV store does not differentiate data by device. If the same key is modified by different devices, the data will be overwritten.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| SINGLE_VERSION | Single KV store.<br>The single KV store does not differentiate data by device. If entries with the same key are modified on different devices, the value will be overwritten.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
## SecurityLevel
## SecurityLevel
...
@@ -135,12 +136,12 @@ Enumerates the KV store security levels.
...
@@ -135,12 +136,12 @@ Enumerates the KV store security levels.
| S1 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.|
| S1 | Low security level. Disclosure, tampering, corruption, or loss of the data may cause minor impact on an individual or group.<br>Examples: gender and nationality information, and user application records |
| S2 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.|
| S2 | Medium security level. Disclosure, tampering, corruption, or loss of the data may cause major impact on an individual or group.<br>Examples: mailing addresses and nicknames of individuals |
| S3 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.|
| S3 | High security level. Disclosure, tampering, corruption, or loss of the data may cause critical impact on an individual or group.<br>Examples: real-time precise positioning information and movement trajectory |
| S4 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.|
| S4 | Critical security level. Disclosure, tampering, corruption, or loss of the data may cause significant adverse impact on an individual or group.<br>Examples: political opinions, religious and philosophical belief, trade union membership, genetic data, biological information, health and sexual life status, sexual orientation, device authentication, and personal credit card information |
## Options
## Options
...
@@ -149,10 +150,10 @@ Provides KV store configuration.
...
@@ -149,10 +150,10 @@ Provides KV store configuration.
| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| encrypt | boolean | No | Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| encrypt | boolean | No | Whether to encrypt the KV store. By default, KV stores are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| backup | boolean | No | Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| backup | boolean | No | Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| autoSync | boolean | No | Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC|
| autoSync | boolean | No | Whether to automatically synchronize the KV store data. The value **true** means to automatically synchronize the KV store data; the value **false** (default) means the opposite.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC |
| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
...
@@ -165,7 +166,7 @@ Defines the schema of a KV store. You can create a **Schema** object and place i
...
@@ -165,7 +166,7 @@ Defines the schema of a KV store. You can create a **Schema** object and place i
Obtains the IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses an asynchronous callback to return the result.
Obtains IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses an asynchronous callback to return the result.
Obtains the IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses a promise to return the result.
Obtains IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses a promise to return the result.
Subscribes to service status changes. If a service is terminated, you need to register the callbacks for data change notifications and synchronization complete notifications again. In addition, an error will be returned for a synchronization operation.
Unsubscribes from service status changes. The **deathCallback** parameter must be a callback registered for subscribing to service status changes. Otherwise, the unsubscription will fail.
| event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.|
| event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.|
| deathCallback | Callback<void> | No | Callback for the service status change event. |
| deathCallback | Callback<void> | No | Callback for the service status change event. If this parameter is not specified, all deathCallback subscriptions will be canceled. |
console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
}
}
```
```
## KVStoreResultSet
## KVStoreResultSet
Provides APIs for obtaining the distributed KV store result sets.
Provides APIs for obtaining the distributed KV store result sets. A maximum of eight result sets can be opened at a time.
Before calling any API in **KVStoreResultSet**, you must use **[getKVStore](#getkvstore)** to construct a **SingleKVStore** or **DeviceKVStore** instance.
Before calling any API in **KVStoreResultSet**, you must use **[getKVStore](#getkvstore)** to construct a **SingleKVStore** or **DeviceKVStore** instance.
...
@@ -792,19 +790,19 @@ Obtains the total number of rows in the result set.
...
@@ -792,19 +790,19 @@ Obtains the total number of rows in the result set.
Obtains the current data read position (position from which data is read) in the result set.
Obtains the current data read position (position from which data is read) in the result set. The read position changes with the operations, such as [moveToFirst](#movetofirst) and [moveToLast](#movetolast).
@@ -820,24 +818,24 @@ Obtains the current data read position (position from which data is read) in the
...
@@ -820,24 +818,24 @@ Obtains the current data read position (position from which data is read) in the
| Type | Description |
| Type | Description |
| ------ | ------------------ |
| ------ | ------------------ |
| number | Current data read position obtained.|
| number | Current data read position obtained. The value must be greater than or equal to **-1**. The value **-1** means no data is read; the value **0** indicates the first row.|
Moves the data read position to the next row. If the result set is empty, **false** will be returned.
Moves the data read position to the next row. If the result set is empty, **false** will be returned. This API applies when the whole result set is obtained.
Moves the data read position to the previous row. If the result set is empty, **false** will be returned.
Moves the data read position to the previous row. If the result set is empty, **false** will be returned. This API applies when the whole result set is obtained.
Moves the data read position with the specified offset from the current position.
Moves the data read position with the specified offset from the current position. That is, move the number of rows specified by **offset** from the current position.
@@ -1250,12 +1249,12 @@ Resets the **Query** object.
...
@@ -1250,12 +1249,12 @@ Resets the **Query** object.
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.equalTo("key","value");
query.equalTo("key","value");
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query.reset();
query.reset();
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query=null;
query=null;
}catch(e){
}catch(e){
console.log("simply calls should be ok :"+e);
console.error("simply calls should be ok :"+e);
}
}
```
```
...
@@ -1286,7 +1285,7 @@ Creates a **Query** object to match the specified field whose value is equal to
...
@@ -1286,7 +1285,7 @@ Creates a **Query** object to match the specified field whose value is equal to
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.equalTo("field","value");
query.equalTo("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.ode is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.ode is ${e.code},message is ${e.message}`);
...
@@ -1320,7 +1319,7 @@ Creates a **Query** object to match the specified field whose value is not equal
...
@@ -1320,7 +1319,7 @@ Creates a **Query** object to match the specified field whose value is not equal
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.notEqualTo("field","value");
query.notEqualTo("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1353,7 +1352,7 @@ Creates a **Query** object to match the specified field whose value is greater t
...
@@ -1353,7 +1352,7 @@ Creates a **Query** object to match the specified field whose value is greater t
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.greaterThan("field","value");
query.greaterThan("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1388,7 +1387,7 @@ Creates a **Query** object to match the specified field whose value is less than
...
@@ -1388,7 +1387,7 @@ Creates a **Query** object to match the specified field whose value is less than
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.lessThan("field","value");
query.lessThan("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1423,7 +1422,7 @@ Creates a **Query** object to match the specified field whose value is greater t
...
@@ -1423,7 +1422,7 @@ Creates a **Query** object to match the specified field whose value is greater t
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.greaterThanOrEqualTo("field","value");
query.greaterThanOrEqualTo("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1458,7 +1457,7 @@ Creates a **Query** object to match the specified field whose value is less than
...
@@ -1458,7 +1457,7 @@ Creates a **Query** object to match the specified field whose value is less than
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.lessThanOrEqualTo("field","value");
query.lessThanOrEqualTo("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1491,7 +1490,7 @@ Creates a **Query** object to match the specified field whose value is **null**.
...
@@ -1491,7 +1490,7 @@ Creates a **Query** object to match the specified field whose value is **null**.
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.isNull("field");
query.isNull("field");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1525,7 +1524,7 @@ Creates a **Query** object to match the specified field whose value is within th
...
@@ -1525,7 +1524,7 @@ Creates a **Query** object to match the specified field whose value is within th
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.inNumber("field",[0,1]);
query.inNumber("field",[0,1]);
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1559,7 +1558,7 @@ Creates a **Query** object to match the specified field whose value is within th
...
@@ -1559,7 +1558,7 @@ Creates a **Query** object to match the specified field whose value is within th
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.inString("field",['test1','test2']);
query.inString("field",['test1','test2']);
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1593,7 +1592,7 @@ Creates a **Query** object to match the specified field whose value is not withi
...
@@ -1593,7 +1592,7 @@ Creates a **Query** object to match the specified field whose value is not withi
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.notInNumber("field",[0,1]);
query.notInNumber("field",[0,1]);
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1627,7 +1626,7 @@ Creates a **Query** object to match the specified field whose value is not withi
...
@@ -1627,7 +1626,7 @@ Creates a **Query** object to match the specified field whose value is not withi
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.notInString("field",['test1','test2']);
query.notInString("field",['test1','test2']);
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1661,7 +1660,7 @@ Creates a **Query** object to match the specified field whose value is similar t
...
@@ -1661,7 +1660,7 @@ Creates a **Query** object to match the specified field whose value is similar t
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.like("field","value");
query.like("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1695,7 +1694,7 @@ Creates a **Query** object to match the specified field whose value is not simil
...
@@ -1695,7 +1694,7 @@ Creates a **Query** object to match the specified field whose value is not simil
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.unlike("field","value");
query.unlike("field","value");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1724,10 +1723,10 @@ try {
...
@@ -1724,10 +1723,10 @@ try {
query.notEqualTo("field","value1");
query.notEqualTo("field","value1");
query.and();
query.and();
query.notEqualTo("field","value2");
query.notEqualTo("field","value2");
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query=null;
query=null;
}catch(e){
}catch(e){
console.log("duplicated calls should be ok :"+e);
console.error("duplicated calls should be ok :"+e);
}
}
```
```
...
@@ -1753,10 +1752,10 @@ try {
...
@@ -1753,10 +1752,10 @@ try {
query.notEqualTo("field","value1");
query.notEqualTo("field","value1");
query.or();
query.or();
query.notEqualTo("field","value2");
query.notEqualTo("field","value2");
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query=null;
query=null;
}catch(e){
}catch(e){
console.log("duplicated calls should be ok :"+e);
console.error("duplicated calls should be ok :"+e);
}
}
```
```
...
@@ -1787,7 +1786,7 @@ try {
...
@@ -1787,7 +1786,7 @@ try {
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.notEqualTo("field","value");
query.notEqualTo("field","value");
query.orderByAsc("field");
query.orderByAsc("field");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1821,7 +1820,7 @@ try {
...
@@ -1821,7 +1820,7 @@ try {
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.notEqualTo("field","value");
query.notEqualTo("field","value");
query.orderByDesc("field");
query.orderByDesc("field");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1832,7 +1831,7 @@ try {
...
@@ -1832,7 +1831,7 @@ try {
limit(total: number, offset: number): Query
limit(total: number, offset: number): Query
Creates a **Query** object to specify the number of results and where to start.
Creates a **Query** object to specify the number of records of the query result and where to start. This API must be called after the invocation of the **orderByAsc()**, **orderByDesc()**, and the query APIs of the **Query** object.
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1891,7 +1890,7 @@ Creates a **Query** object to match the specified field whose value is not **nul
...
@@ -1891,7 +1890,7 @@ Creates a **Query** object to match the specified field whose value is not **nul
try{
try{
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.isNotNull("field");
query.isNotNull("field");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -1920,10 +1919,10 @@ try {
...
@@ -1920,10 +1919,10 @@ try {
query.beginGroup();
query.beginGroup();
query.isNotNull("field");
query.isNotNull("field");
query.endGroup();
query.endGroup();
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query=null;
query=null;
}catch(e){
}catch(e){
console.log("duplicated calls should be ok :"+e);
console.error("duplicated calls should be ok :"+e);
}
}
```
```
...
@@ -1949,10 +1948,10 @@ try {
...
@@ -1949,10 +1948,10 @@ try {
query.beginGroup();
query.beginGroup();
query.isNotNull("field");
query.isNotNull("field");
query.endGroup();
query.endGroup();
console.log("query is "+query.getSqlLike());
console.info("query is "+query.getSqlLike());
query=null;
query=null;
}catch(e){
}catch(e){
console.log("duplicated calls should be ok :"+e);
console.error("duplicated calls should be ok :"+e);
}
}
```
```
...
@@ -1983,7 +1982,7 @@ try {
...
@@ -1983,7 +1982,7 @@ try {
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.prefixKey("$.name");
query.prefixKey("$.name");
query.prefixKey("0");
query.prefixKey("0");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -2017,7 +2016,7 @@ try {
...
@@ -2017,7 +2016,7 @@ try {
letquery=newdistributedKVStore.Query();
letquery=newdistributedKVStore.Query();
query.setSuggestIndex("$.name");
query.setSuggestIndex("$.name");
query.setSuggestIndex("0");
query.setSuggestIndex("0");
console.log(`query is ${query.getSqlLike()}`);
console.info(`query is ${query.getSqlLike()}`);
query=null;
query=null;
}catch(e){
}catch(e){
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`);
...
@@ -2029,6 +2028,10 @@ try {
...
@@ -2029,6 +2028,10 @@ try {
deviceId(deviceId:string):Query
deviceId(deviceId:string):Query
Creates a **Query** object with the device ID as the key prefix.
Creates a **Query** object with the device ID as the key prefix.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the KV pairs to delete. If this parameter is **null**, define the processing logic.|
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the **KVStoreResultSet** object to obtain. If this parameter is **null**, define the processing logic.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Error codes**
**Error codes**
...
@@ -2538,19 +2581,33 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -2538,19 +2581,33 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
| 15100003 | Database corrupted. |
| 15100003 | Database corrupted. |
| 15100005 | Database or result set already closed. |
| 15100005 | Database or result set already closed. |
For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
Deletes data of a device. This API uses an asynchronous callback to return the result.
Deletes data of a device. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Deletes data of a device. This API uses a promise to return the result.
Deletes data of a device. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
Synchronizes the KV store manually. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE**
> **NOTE**<br/>
>
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...
@@ -4516,7 +4579,6 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -4516,7 +4579,6 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE**<br/>
> **NOTE**<br/>
>
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
...
@@ -4587,7 +4649,6 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -4587,7 +4649,6 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result.
Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result.
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object that matches the specified device ID and key prefix.|
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KvStoreResultSet** object that matches the specified device ID and key prefix.|
**Error codes**
**Error codes**
...
@@ -5772,32 +5843,32 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -5772,32 +5843,32 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result.
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise used to return the **KVStoreResultSet** object that matches the specified device ID and key prefix.|
| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise used to return the **KvStoreResultSet** object that matches the specified device ID and key prefix.|
**Error codes**
**Error codes**
...
@@ -5828,28 +5903,28 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -5828,28 +5903,28 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object that matches the specified device ID and **Query** object.|
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KvStoreResultSet** object that matches the specified device ID and **Query** object.|
**Error codes**
**Error codes**
...
@@ -5875,13 +5954,13 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -5875,13 +5954,13 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise used to return the **KVStoreResultSet** object that matches the specified device ID and **Query** object.|
| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise used to return the **KvStoreResultSet** object that matches the specified device ID and **Query** object.|
**Error codes**
**Error codes**
...
@@ -5952,13 +6035,13 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -5952,13 +6035,13 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
Obtains a **KVStoreResultSet** object that matches the specified **Query** object for this device. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the **KVStoreResultSet** object to obtain. If this parameter is **null**, define the processing logic. |
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the KV pairs to delete. If this parameter is **null**, define the processing logic. |
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.|
| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.|
**Error codes**
**Error codes**
...
@@ -6161,6 +6246,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -6161,6 +6246,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the **KVStoreResultSet** object to obtain. If this parameter is **null**, define the processing logic.|
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the KV pairs to delete. If this parameter is **null**, define the processing logic.|
**Return value**
**Return value**
...
@@ -6222,6 +6307,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -6222,6 +6307,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses an asynchronous callback to return the result.
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
**System API**: This is a system API.
**System API**: This is a system API.
...
@@ -6275,6 +6364,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -6275,6 +6364,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses a promise to return the result.
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
**System API**: This is a system API.
**System API**: This is a system API.
...
@@ -6323,7 +6416,7 @@ Obtains a **KVStoreResultSet** object that matches the specified predicate objec
...
@@ -6323,7 +6416,7 @@ Obtains a **KVStoreResultSet** object that matches the specified predicate objec
| deviceId | string | Yes | ID of the target device. |
| deviceId | string | Yes | ID of the target device. |
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the **KVStoreResultSet** object to obtain. If this parameter is **null**, define the processing logic.|
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | **DataSharePredicates** object that specifies the KV pairs to delete. If this parameter is **null**, define the processing logic.|
**Return value**
**Return value**
...
@@ -6337,6 +6430,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
...
@@ -6337,6 +6430,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result.
Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).