>The initial APIs of this module are supported since API version 7. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -230,7 +229,7 @@ Closes a KV store. This method uses an asynchronous callback to return the resul
...
@@ -230,7 +229,7 @@ Closes a KV store. This method uses an asynchronous callback to return the resul
| appId | string | Yes| Bundle name of the app used by the KV store.|
| appId | string | Yes| Bundle name of the app that invokes the KV store.|
| storeId | string | Yes| Unique identifier of the KV store to close. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).|
| storeId | string | Yes| Unique identifier of the KV store to close. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).|
| kvStore | [KVStore](#kvstore) | Yes| KV store to close.|
| kvStore | [KVStore](#kvstore) | Yes| KV store to close.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.|
...
@@ -273,7 +272,7 @@ Closes a KV store. This method uses a promise to return the result.
...
@@ -273,7 +272,7 @@ Closes a KV store. This method uses a promise to return the result.
| appId | string | Yes| Bundle name of the app used by the KV store.|
| appId | string | Yes| Bundle name of the app that invokes the KV store.|
| storeId | string | Yes| Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).|
| storeId | string | Yes| Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is deleted, **true** will be returned. Otherwise, **false** will be returned.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is deleted, **true** will be returned. Otherwise, **false** will be returned.|
...
@@ -367,7 +366,7 @@ Deletes a KV store. This method uses a promise to return the result.
...
@@ -367,7 +366,7 @@ Deletes a KV store. This method uses a promise to return the result.
| appId | string | Yes| Bundle name of the app used by the KV store.|
| appId | string | Yes| Bundle name of the app that invokes the KV store.|
- Return value
- Return value
...
@@ -545,7 +544,7 @@ Provides KV store configuration.
...
@@ -545,7 +544,7 @@ 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.|
| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.|
| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.|
| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.|
| backup | boolean | No|Whether to back up database files. By default, database files are backed up. |
| backup | boolean | No|Whether to back up database files. By default, database files are backed up. |
| autoSync | boolean | No|Whether database files are automatically synchronized. By default, database files are not automatically synchronized.|
| autoSync | boolean | No|Whether to automatically synchronize database files. By default, database files are not automatically synchronized.|
| 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.|
| 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.|
| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.|
| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.|
...
@@ -585,7 +584,7 @@ Defines the KV store constants.
...
@@ -585,7 +584,7 @@ Defines the KV store constants.
| MAX\_KEY_LENGTH| 1024 | Maximum length (in bytes) of a key in the KV store.|
| MAX\_KEY_LENGTH| 1024 | Maximum length (in bytes) of a key in the KV store.|
| MAX\_VALUE_LENGTH| 4194303 | Maximum length (in bytes) of a value in the KV store.|
| MAX\_VALUE_LENGTH| 4194303 | Maximum length (in bytes) of a value in the KV store.|
| MAX\_KEY\_LENGTH\_DEVICE| 896 | Maximum length of the device coordinate key.|
| MAX\_KEY\_LENGTH\_DEVICE| 896 | Maximum length of the device coordinate key.|
| MAX\_STORE\_ID\_LENGTH| 128 | Maximum length (in bytes) of the KV store ID.|
| MAX\_STORE\_ID\_LENGTH| 128 | Maximum length (in bytes) of a KV store ID.|
| MAX\_QUERY_LENGTH| 512000 | Maximum query length.|
| MAX\_QUERY_LENGTH| 512000 | Maximum query length.|
| MAX\_BATCH_SIZE| 128 | Maximum size of a batch operation.|
| MAX\_BATCH_SIZE| 128 | Maximum size of a batch operation.|
...
@@ -633,7 +632,7 @@ Adds a child node to this **FieldNode**.
...
@@ -633,7 +632,7 @@ Adds a child node to this **FieldNode**.
| child | [FieldNode](#FieldNode) | Yes| Field node to add.|
| child | [FieldNode](#FieldNode) | Yes| Child node to add.|
- Return value
- Return value
...
@@ -694,7 +693,7 @@ Obtains the field name.
...
@@ -694,7 +693,7 @@ Obtains the field name.
## KvStoreResultSet<sup>8+</sup> ##
## KvStoreResultSet<sup>8+</sup> ##
Provides methods to obtain the KV Store result set and query or move the data read position. Before calling **KvStoreResultSet**, you must create a **KvStore** instance using **KvStore**.
Provides methods to obtain the KV store result set and query or move the data read position. Before calling any method in **KvStoreResultSet**, you must use **KvStore** to create a **KvStore** instance.
### getCount<sup>8+</sup> ###
### getCount<sup>8+</sup> ###
...
@@ -936,7 +935,7 @@ Moves the data read position from 0 to an absolute position.
...
@@ -936,7 +935,7 @@ Moves the data read position from 0 to an absolute position.
| index | string | Yes|Index preferentially used for query.|
- Return value
- Return value
...
@@ -1956,13 +1955,13 @@ Obtains the query statement of this **Query** object.
...
@@ -1956,13 +1955,13 @@ Obtains the query statement of this **Query** object.
## KVStore
## KVStore
Provides methods to manage data in a KV store, for example, adding or deleting data and subscribing to data changes or completion of data synchronization. Before calling any method in **KVStore**, you must use **getKVStore** to create a **KVStore** object.
Provides methods to manage data in a KV store, for example, adding or deleting data and subscribing to data changes or completion of data synchronization. Before calling any method in **KVStore**, you must use **getKVStore** to obtain a **KVStore** object.
| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and the value **false** means the opposite.|
| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite.|
| callback |AsyncCallback<void> | Yes|Callback used to return the result.|
| callback |AsyncCallback<void> | Yes|Callback used to return the result.|
- Example
- Example
...
@@ -2623,7 +2622,7 @@ Sets data synchronization, which can be enabled or disable. This method uses a p
...
@@ -2623,7 +2622,7 @@ Sets data synchronization, which can be enabled or disable. This method uses a p
| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and the value **false** means the opposite.|
| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite.|
- Return value
- Return value
...
@@ -2657,7 +2656,7 @@ Sets the data synchronization range. This method uses an asynchronous callback t
...
@@ -2657,7 +2656,7 @@ Sets the data synchronization range. This method uses an asynchronous callback t
| key | string | Yes| Yes|Key of the KV pair stored in the database.|
| key | string | Yes| Yes|Key of the KV pair stored in the KV store.|
| value | [Value](#value) | Yes| Yes|Value of the KV pair stored in the database.|
| value | [Value](#value) | Yes| Yes|Value of the KV pair stored in the KV store.|
## Value
## Value
...
@@ -2757,9 +2756,9 @@ Defines the value in a KV pair.
...
@@ -2757,9 +2756,9 @@ Defines the value in a KV pair.
## ValueType
## ValueType
Defines the types of the value in a KV pair.
Enumerates the types of values in KV pairs.
It can be used only by internal applications.
These value types can be used only by internal applications.
| Name| Default Value| Description|
| Name| Default Value| Description|
| ----- | ------ | ----------------------- |
| ----- | ------ | ----------------------- |
...
@@ -2772,7 +2771,7 @@ It can be used only by internal applications.
...
@@ -2772,7 +2771,7 @@ It can be used only by internal applications.
## SingleKVStore
## SingleKVStore
Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use **getKVStore** to create a **SingleKVStore** object.
Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use **getKVStore** to obtain a **SingleKVStore** object.
### get
### get
...
@@ -2785,7 +2784,7 @@ Obtains the value of a specified key. This method uses an asynchronous callback
...
@@ -2785,7 +2784,7 @@ Obtains the value of a specified key. This method uses an asynchronous callback
| callback |AsyncCallback<[SecurityLevel](#securitylevel)> | Yes|Callback used to return the result.|
| callback |AsyncCallback<[SecurityLevel](#securitylevel)> | Yes|Callback used to return the security level obtained.|
- Example
- Example
...
@@ -3692,13 +3691,13 @@ Obtains the security level of a KV store. This method uses an asynchronous callb
...
@@ -3692,13 +3691,13 @@ Obtains the security level of a KV store. This method uses an asynchronous callb
getSecurityLevel(): Promise<SecurityLevel>;
getSecurityLevel(): Promise<SecurityLevel>;
Obtains the security level of a KV store. This method uses a promise to return the result.
Obtains the security level of this KV store. This method uses a promise to return the result.
- Return value
- Return value
| Type| Description|
| Type| Description|
| ------ | ------- |
| ------ | ------- |
|Promise<[SecurityLevel](#securitylevel)> |Promise used to return the result.|
|Promise<[SecurityLevel](#securitylevel)> |Promise used to return the security level obtained.|
- Example
- Example
...
@@ -3719,7 +3718,7 @@ Obtains the security level of a KV store. This method uses a promise to return t
...
@@ -3719,7 +3718,7 @@ Obtains the security level of a KV store. This method uses a promise to return t
## DeviceKVStore<sup>8+</sup> ##
## DeviceKVStore<sup>8+</sup> ##
Provides methods to manage distributed data by device in the distributed system. This class inherits from **KvStore** and provides data query and synchronization methods. Before calling any method in **DeviceKVStore**, you must use **getKVStore** to create a **DeviceKVStore** object.
Provides methods to manage distributed data by device in the distributed system. This class inherits from **KvStore** and provides data query and synchronization methods. Before calling any method in **DeviceKVStore**, you must use **getKVStore** to obtain a **DeviceKVStore** object.
### get<sup>8+</sup> ###
### get<sup>8+</sup> ###
...
@@ -3772,7 +3771,7 @@ Obtains the string value that matches the specified key for a device. This metho
...
@@ -3772,7 +3771,7 @@ Obtains the string value that matches the specified key for a device. This metho
| Type| Description|
| Type| Description|
| ------ | ------- |
| ------ | ------- |
|Promise<boolean/string/number/Uint8Array> |Promise used to return the result.|
|Promise<boolean/string/number/Uint8Array> |Promise used to return the value obtained.|
- Example
- Example
...
@@ -3801,7 +3800,7 @@ Obtains the string value that matches the specified key for a device. This metho
...
@@ -3801,7 +3800,7 @@ Obtains the string value that matches the specified key for a device. This metho
| query |[Query](#querysup8sup) | Yes|**Query** object to match.|
| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.|
| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.|
- Example
- Example
...
@@ -4252,13 +4251,13 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj
...
@@ -4252,13 +4251,13 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj
| query |[Query](#querysup8sup) | Yes|**Query** object to match.|
| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.|
| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.|
- Example
- Example
...
@@ -4365,13 +4364,13 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj
...
@@ -4365,13 +4364,13 @@ Obtains the **KvStoreResultSet** object that matches the specified **Query** obj