未验证 提交 1ae64b84 编写于 作者: O openharmony_ci 提交者: Gitee

!17992 [翻译完成】PR17296

Merge pull request !17992 from Annie_wang/PR17296
......@@ -32,7 +32,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
## How to Develop
1. Create a **KvManager** instance to manage database objects. Example:
1. Create a **KvManager** instance to manage database objects.
Example:
Stage model:
......@@ -90,7 +92,9 @@ The following table lists the APIs used for KV data persistence. Most of the API
}
```
2. Create and obtain a KV store. Example:
2. Create and obtain a KV store.
Example:
```js
try {
......@@ -116,7 +120,9 @@ 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:
3. Use **put()** to add data to the KV store.
Example:
```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
......@@ -138,7 +144,9 @@ 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:
4. Use **get()** to obtain the value of a key.
Example:
```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
......@@ -163,7 +171,9 @@ 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:
5. Use **delete()** to delete the data of the specified key.
Example:
```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
......
......@@ -30,7 +30,7 @@ The preference persistent file of an application is stored in the application sa
The following table lists the APIs used for preferences 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 [User Preferences](../reference/apis/js-apis-data-preferences.md).
| API| Description|
| API| Description|
| -------- | -------- |
| getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void | Obtain a **Preferences** instance.|
| put(key: string, value: ValueType, callback: AsyncCallback<void>): void | Writes data to the Preferences instance. You can use **flush()** to persist the **Preferences** instance data.|
......@@ -143,7 +143,9 @@ The following table lists the APIs used for preferences data persistence. Most o
4. Read data.
Use **get()** to obtain the value of the specified key. If the value is null or is not of the default value type, the default data is returned. Example:
Use **get()** to obtain the value of the specified key. If the value is null or is not of the default value type, the default data is returned.
Example:
```js
try {
......@@ -159,7 +161,7 @@ The following table lists the APIs used for preferences data persistence. Most o
}
```
5. Deletes data.
5. Delete data.
Use delete() to delete a KV pair.<br>Example:
......
......@@ -118,7 +118,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
>
> - When an application calls **getRdbStore()** to obtain an RDB store instance for the first time, the corresponding database file is generated in the application sandbox. If you want to move the files of an RDB store to another place for view, you must also move the temporary files with finename extensions **-wal** or **-shm** in the same directory. Once an application is uninstalled, the database files and temporary files generated by the application on the device are also removed.
2. Use **insert()** to insert data to the RDB store. Example:
2. Use **insert()** to insert data to the RDB store.
Example:
```js
const valueBucket = {
......@@ -133,16 +135,18 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
return;
}
console.info(`Succeeded in inserting data. rowId:${rowId}`);
})
})
```
> **NOTE**
>
>
> **RelationalStore** does not provide explicit flush operations for data persistence. Data inserted by **insert()** is stored in files persistently.
3. Modify or delete data based on the specified **Predicates** instance.
Use **update()** to modify data and **delete()** to delete data. Example:
Use **update()** to modify data and **delete()** to delete data.
Example:
```js
// Modify data.
......@@ -176,7 +180,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
4. Query data based on the conditions specified by **Predicates**.
Use **query()** to query data. The data obtained is returned in a **ResultSet** object. Example:
Use **query()** to query data. The data obtained is returned in a **ResultSet** object.
Example:
```js
let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
......@@ -197,7 +203,9 @@ The following table lists the APIs used for RDB data persistence. Most of the AP
5. Delete the RDB store.
Use **deleteRdbStore()** to delete the RDB store and related database files. Example:
Use **deleteRdbStore()** to delete the RDB store and related database files.
Example:
Stage model:
......
......@@ -91,7 +91,7 @@ The following table lists the APIs for cross-device data synchronization of the
## How to Develop
The following uses a single KV store as an example to describe how to implement cross-device data synchronization. The following describes the development process.
The following uses a single KV store as an example to describe how to implement cross-device data synchronization. The development process is as follows.
![kvStore_development_process](figures/kvStore_development_process.png)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册