From e2189e9241061b6fc43e5a481da15ced8458c519 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Mon, 22 May 2023 16:17:58 +0800 Subject: [PATCH] fixed 2800d10 from https://gitee.com/Annie_wang/docs/pulls/18490 update docs Signed-off-by: Annie_wang --- .../database/data-persistence-by-kv-store.md | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/en/application-dev/database/data-persistence-by-kv-store.md b/en/application-dev/database/data-persistence-by-kv-store.md index 804fb6b127..2337702fb7 100644 --- a/en/application-dev/database/data-persistence-by-kv-store.md +++ b/en/application-dev/database/data-persistence-by-kv-store.md @@ -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. Example: - Stage model: - + ```js // Import the module. import distributedKVStore from '@ohos.data.distributedKVStore'; @@ -69,7 +68,7 @@ The following table lists the APIs used for KV data persistence. Most of the API FA model: - + ```js // Import the module. import distributedKVStore from '@ohos.data.distributedKVStore'; @@ -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 { const options = { 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 ``` 3. Use **put()** to add data to the KV store. - + Example: - ```js const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value_test_string'; @@ -145,9 +142,8 @@ The following table lists the APIs used for KV data persistence. Most of the API > The **put()** method adds a KV pair if the specified key does not exists and changes the value if the the specified key already exists. 4. Use **get()** to obtain the value of a key. - + Example: - ```js const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value_test_string'; @@ -172,9 +168,8 @@ The following table lists the APIs used for KV data persistence. Most of the API ``` 5. Use **delete()** to delete the data of the specified key. - + Example: - ```js const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value_test_string'; -- GitLab