@@ -21,13 +21,13 @@ The key-value (KV) database stores data in the form of KV pairs. You can use KV
The following table lists the APIs used for KV data persistence. Most of the APIs are executed asynchronously, using a callback or promise to return the result. The following table uses the callback-based APIs as an example. For more information about the APIs, see [Distributed KV Store](../reference/apis/js-apis-distributedKVStore.md).
| API| Description|
| API| Description|
| -------- | -------- |
| createKVManager(config: KVManagerConfig): KVManager | Creates a **KvManager** instance to manage database objects.|
| getKVStore<T>(storeId: string, options: Options, callback: AsyncCallback<T>): void | Creates and obtains a KV store of the specified type.|
| put(key: string, value: Uint8Array\|string\|number\|boolean, callback: AsyncCallback<void>): void | Adds a KV pair of the specified type to this KV store.|
| get(key: string, callback: AsyncCallback<Uint8Array\|string\|boolean\|number>): void | Obtains the value of the specified key.|
| delete(key: string, callback: AsyncCallback<void>): void | Deletes a KV pair based on the specified key.|
| createKVManager(config: KVManagerConfig): KVManager | Creates a **KvManager** instance to manage database objects.|
| getKVStore<T>(storeId: string, options: Options, callback: AsyncCallback<T>): void | Creates and obtains a KV store of the specified type.|
| put(key: string, value: Uint8Array\|string\|number\|boolean, callback: AsyncCallback<void>): void | Adds a KV pair of the specified type to this KV store.|
| get(key: string, callback: AsyncCallback<Uint8Array\|string\|boolean\|number>): void | Obtains the value of the specified key.|
| delete(key: string, callback: AsyncCallback<void>): void | Deletes a KV pair based on the specified key.|
## How to Develop
...
...
@@ -35,10 +35,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
1. Create a **KvManager** instance to manage database objects.
@@ -93,14 +92,13 @@ The following table lists the APIs used for KV data persistence. Most of the API
```
2. Create and obtain a KV store.
Example:
```js
try{
constoptions={
createIfMissing:true,// Whether to create a KV store when the database file does not exist. By default, a KV store is created.
createIfMissing:true,// Whether to encrypt database files. By default, database files are not encrypted.
encrypt:false,// Whether to encrypt the KV store. By default, KV stores are not encrypted.
backup:false,// Whether to back up database files. By default, the database files are backed up.
autoSync:true,// Whether to automatically synchronize database files. The value **true** means to automatically synchronize database files; the value **false** (default) means the opposite.
kvStoreType:distributedKVStore.KVStoreType.SINGLE_VERSION,// Type of the KV store to create. By default, a device KV store is created.
...
...
@@ -121,9 +119,8 @@ The following table lists the APIs used for KV data persistence. Most of the API