提交 e21e796d 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 028fdcb7
......@@ -16,6 +16,8 @@ This module provides the following functions:
>- The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md).
>
>- 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.
>
>- All the APIs that need to obtain **deviceId** in this module are available only to system applications.
## Modules to Import
......@@ -88,25 +90,22 @@ Creates a **KVManager** instance to manage KV stores. This API uses a promise to
**Example**
```js
let kvManager;
try {
const kvManagerConfig = {
bundleName : 'com.example.datamanagertest',
userInfo : {
userId : '0',
userType : distributedData.UserType.SAME_USER_ID
}
const kvManagerConfig = {
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager successfully");
kvManager = manager;
});
}
distributedData.createKVManager(kvManagerConfig).then((manager) => {
console.log("Created KVManager successfully");
kvManager = manager;
}).catch((err) => {
console.error("Failed to create KVManager: " + JSON.stringify(err));
});
} catch (e) {
console.log("An unexpected error occurred. Error:" + e);
console.log("An unexpected error occurred. Error:" + e);
}
```
......@@ -212,7 +211,7 @@ Creates and obtains a KV store. This API uses a promise to return the result.
| Type | Description |
| -------------------------------------- | ------------------------ |
| Promise&lt;T&gt;, &lt;T extends [KVStore](#kvstore)&gt; | Promise used to return the KV store instance created. |
| Promise&lt;T&gt;, &lt;T extends [KVStore](#kvstore)&gt; | Promise used to return the KV store instance created.|
**Example**
......@@ -485,7 +484,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore)
| Type | Description |
| ------------- | -------------- |
| Promise&lt;string[]&gt;| Promise used to return the IDs of all created KV stores. |
| Promise&lt;string[]&gt;| Promise used to return the IDs of all created KV stores.|
**Example**
......@@ -2012,6 +2011,10 @@ try {
deviceId(deviceId:string):Query
Creates a **Query** object with the device ID as the key prefix.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.Core
......@@ -3664,6 +3667,10 @@ try {
removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data of a device. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.Core
......@@ -3706,6 +3713,10 @@ try {
removeDeviceData(deviceId: string): Promise&lt;void&gt;
Deletes data of a device. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.Core
......@@ -3754,8 +3765,8 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
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).
> **NOTE**<br/>
Synchronizes the KV store manually.
> **NOTE**
>
> 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.
......@@ -3825,7 +3836,7 @@ Subscribes to data changes of the specified type.
| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------- |
| event | string | Yes | Event to subscribe to. The value is **dataChange**, which indicates a data change event.|
| type | [SubscribeType](#subscribetype) | Yes | Type of data change. |
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes | Callback invoked to return the result. |
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes | Callback invoked to return a data change event. |
**Example**
......@@ -4084,6 +4095,10 @@ Before calling any method in **DeviceKVStore**, you must use [getKVStore](#getkv
get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean|string|number|Uint8Array&gt;): void
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4119,6 +4134,10 @@ try{
get(deviceId: string, key: string): Promise&lt;boolean|string|number|Uint8Array&gt;
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4163,6 +4182,10 @@ try {
getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void
Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4211,6 +4234,10 @@ try {
getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt;
Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4380,6 +4407,10 @@ try {
getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4433,6 +4464,10 @@ try {
getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt;
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4493,6 +4528,10 @@ try {
getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KvStoreResultSet&gt;): void
Obtains a **KvStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4528,6 +4567,10 @@ try {
getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KvStoreResultSet&gt;
Obtains a **KvStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4688,6 +4731,10 @@ try {
getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KvStoreResultSet&gt;): void
Obtains a **KvStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4740,6 +4787,10 @@ try {
getResultSet(deviceId: string, query: Query): Promise&lt;KvStoreResultSet&gt;
Obtains a **KvStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -4982,6 +5033,10 @@ try {
getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number&gt;): void;
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**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -5029,6 +5084,10 @@ try {
getResultSize(deviceId: string, query: Query): Promise&lt;number&gt;
Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -5085,6 +5144,10 @@ try {
removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data of the specified device from this KV store. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -5127,6 +5190,10 @@ try {
removeDeviceData(deviceId: string): Promise&lt;void&gt;
Deletes data of the specified device from this KV store. This API uses a promise to return the result.
> **NOTE**
>
> **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 capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
......@@ -5175,9 +5242,9 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
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.
> **NOTE**<br/>
> **NOTE**
>
> 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.
......@@ -5247,7 +5314,7 @@ Subscribes to data changes of the specified type.
| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------- |
| event | string | Yes | Event to subscribe to. The value is **dataChange**, which indicates a data change event.|
| type | [SubscribeType](#subscribetype) | Yes | Type of data change. |
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes | Callback invoked to return the result. |
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes | Callback invoked to return a data change event. |
**Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册