提交 629b0425 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 af822aea
...@@ -50,16 +50,39 @@ The following uses a single KV store as an example to describe the development p ...@@ -50,16 +50,39 @@ The following uses a single KV store as an example to describe the development p
This permission must also be granted by the user when the application is started for the first time. The sample code is as follows: This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
```js ```js
// FA model
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
function grantPermission() { function grantPermission() {
console.info('grantPermission'); console.info('grantPermission');
let context = featureAbility.getContext(); let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => {
console.info(`result.requestCode=${result.requestCode}`) console.info('success: ${data}');
}).catch((error) => {
console.info('failed: ${error}');
}) })
console.info('end grantPermission'); }
grantPermission();
// Stage model
import Ability from '@ohos.application.Ability';
let context = null;
function grantPermission() {
class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
let context = this.context;
}
}
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success: ${data}');
}).catch((error) => {
console.log('failed: ${error}');
});
} }
grantPermission(); grantPermission();
...@@ -73,25 +96,39 @@ The following uses a single KV store as an example to describe the development p ...@@ -73,25 +96,39 @@ The following uses a single KV store as an example to describe the development p
The sample code is as follows: The sample code is as follows:
```js ```js
// Obtain the context of the FA model.
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
// Obtain the context of the stage model.
import AbilityStage from '@ohos.application.Ability';
let context = null;
class MainAbility extends AbilityStage{
onWindowStageCreate(windowStage){
context = this.context;
}
}
let kvManager; let kvManager;
try { try {
const kvManagerConfig = { const kvManagerConfig = {
bundleName: 'com.example.datamanagertest', bundleName: 'com.example.datamanagertest',
userInfo: { userInfo: {
context:context,
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) { distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) { if (err) {
console.log("createKVManager err: " + JSON.stringify(err)); console.log('Failed to create KVManager: ${error}');
return; return;
} }
console.log("createKVManager success"); console.log('Created KVManager successfully');
kvManager = manager; kvManager = manager;
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error: " + e); console.log('An unexpected error occurred. Error: ${e}');
} }
``` ```
...@@ -115,14 +152,14 @@ The following uses a single KV store as an example to describe the development p ...@@ -115,14 +152,14 @@ The following uses a single KV store as an example to describe the development p
}; };
kvManager.getKVStore('storeId', options, function (err, store) { kvManager.getKVStore('storeId', options, function (err, store) {
if (err) { if (err) {
console.log("getKVStore err: " + JSON.stringify(err)); console.log('Failed to get KVStore: ${err}');
return; return;
} }
console.log("getKVStore success"); console.log('Got KVStore successfully');
kvStore = store; kvStore = store;
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error: " + e); console.log('An unexpected error occurred. Error: ${e}');
} }
``` ```
...@@ -136,7 +173,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -136,7 +173,7 @@ The following uses a single KV store as an example to describe the development p
```js ```js
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.log("dataChange callback call data: " + JSON.stringify(data)); console.log("dataChange callback call data: ${data}");
}); });
``` ```
...@@ -153,13 +190,13 @@ The following uses a single KV store as an example to describe the development p ...@@ -153,13 +190,13 @@ The following uses a single KV store as an example to describe the development p
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.log("put err: " + JSON.stringify(err)); console.log('Failed to put data: ${error}');
return; return;
} }
console.log("put success"); console.log('Put data successfully');
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error: " + e); console.log('An unexpected error occurred. Error: ${e}');
} }
``` ```
...@@ -176,16 +213,16 @@ The following uses a single KV store as an example to describe the development p ...@@ -176,16 +213,16 @@ The following uses a single KV store as an example to describe the development p
try { try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.log("put err: " + JSON.stringify(err)); console.log('Failed to put data: ${error}');
return; return;
} }
console.log("put success"); console.log('Put data successfully');
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
console.log("get success data: " + data); console.log('Got data successfully: ${data}');
}); });
}); });
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error: " + e); console.log('An unexpected error occurred. Error: ${e}');
} }
``` ```
...@@ -204,7 +241,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -204,7 +241,7 @@ The following uses a single KV store as an example to describe the development p
let devManager; let devManager;
// Create deviceManager. // Create deviceManager.
deviceManager.createDeviceManager("bundleName", (err, value) => { deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) { if (!err) {
devManager = value; devManager = value;
// deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync(). // deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync().
...@@ -219,7 +256,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -219,7 +256,7 @@ The following uses a single KV store as an example to describe the development p
// 1000 indicates that the maximum delay is 1000 ms. // 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000);
} catch (e) { } catch (e) {
console.log("An unexpected error occurred. Error: " + e); console.log('An unexpected error occurred. Error: ${e}');
} }
} }
}); });
......
...@@ -70,30 +70,25 @@ export default class MyAbilityStage extends AbilityStage { ...@@ -70,30 +70,25 @@ export default class MyAbilityStage extends AbilityStage {
FA model: FA model:
```js ```js
import AbilityStage from '@ohos.application.Ability' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = this.context
const kvManagerConfig = {
context: context.getApplicationContext(),
bundleName: 'com.example.datamanagertest', bundleName: 'com.example.datamanagertest',
userInfo: { userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) { distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) { if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err)); console.log("Failed to create KVManager: " + JSON.stringify(err));
return; return;
} }
console.log("Created KVManager successfully"); console.log("Created KVManager successfully");
kvManager = manager; kvManager = manager;
}); });
}
}
``` ```
## distributedData.createKVManager ## distributedData.createKVManager
...@@ -134,13 +129,11 @@ export default class MyAbilityStage extends AbilityStage { ...@@ -134,13 +129,11 @@ export default class MyAbilityStage extends AbilityStage {
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) { distributedData.createKVManager(kvManagerConfig).then((manager) => {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager successfully"); console.log("Created KVManager successfully");
kvManager = manager; kvManager = manager;
}).catch((err) => {
console.log("Failed to create KVManager: " + JSON.stringify(err));
}); });
} }
} }
...@@ -148,30 +141,23 @@ export default class MyAbilityStage extends AbilityStage { ...@@ -148,30 +141,23 @@ export default class MyAbilityStage extends AbilityStage {
FA model: FA model:
```js ```js
import AbilityStage from '@ohos.application.Ability' import featureAbility from '@ohos.ability.featureAbility'
let kvManager; let kvManager;
export default class MyAbilityStage extends AbilityStage { let context = featureAbility.getContext()
onCreate() { const kvManagerConfig = {
console.log("MyAbilityStage onCreate") context: context,
let context = this.context
const kvManagerConfig = {
context: context.getApplicationContext(),
bundleName: 'com.example.datamanagertest', bundleName: 'com.example.datamanagertest',
userInfo: { userInfo: {
userId: '0', userId: '0',
userType: distributedData.UserType.SAME_USER_ID userType: distributedData.UserType.SAME_USER_ID
} }
} }
distributedData.createKVManager(kvManagerConfig, function (err, manager) { distributedData.createKVManager(kvManagerConfig).then((manager) => {
if (err) {
console.log("Failed to create KVManager: " + JSON.stringify(err));
return;
}
console.log("Created KVManager successfully"); console.log("Created KVManager successfully");
kvManager = manager; kvManager = manager;
}); }).catch((err) => {
} console.log("Failed to create KVManager: " + JSON.stringify(err));
} });
``` ```
## KVManagerConfig ## KVManagerConfig
...@@ -320,7 +306,7 @@ Closes a KV store. This API uses an asynchronous callback to return the result. ...@@ -320,7 +306,7 @@ Closes a KV store. This API uses an asynchronous callback to return the result.
| appId | string | Yes | Bundle name of the app that invokes 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 [MAX_STORE_ID_LENGTH](#constants).| | storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).|
| kvStore | [KVStore](#kvstore) | Yes | KV store to close. | | kvStore | [KVStore](#kvstore) | Yes | KV store to close. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Example** **Example**
...@@ -328,15 +314,15 @@ Closes a KV store. This API uses an asynchronous callback to return the result. ...@@ -328,15 +314,15 @@ Closes a KV store. This API uses an asynchronous callback to return the result.
let kvStore; let kvStore;
let kvManager; let kvManager;
const options = { const options = {
createIfMissing : true, createIfMissing: true,
encrypt : false, encrypt: false,
backup : false, backup: false,
autoSync : true, autoSync: true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema: '',
securityLevel : distributedData.SecurityLevel.S2, securityLevel: distributedData.SecurityLevel.S2,
} }
try { try {
kvManager.getKVStore('storeId', options, async function (err, store) { kvManager.getKVStore('storeId', options, async function (err, store) {
console.log('getKVStore success'); console.log('getKVStore success');
kvStore = store; kvStore = store;
...@@ -378,15 +364,15 @@ Closes a KV store. This API uses a promise to return the result. ...@@ -378,15 +364,15 @@ Closes a KV store. This API uses a promise to return the result.
let kvManager; let kvManager;
let kvStore; let kvStore;
const options = { const options = {
createIfMissing : true, createIfMissing: true,
encrypt : false, encrypt: false,
backup : false, backup: false,
autoSync : true, autoSync: true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema: '',
securityLevel : distributedData.SecurityLevel.S2, securityLevel: distributedData.SecurityLevel.S2,
} }
try { try {
kvManager.getKVStore('storeId', options).then(async (store) => { kvManager.getKVStore('storeId', options).then(async (store) => {
console.log('getKVStore success'); console.log('getKVStore success');
kvStore = store; kvStore = store;
...@@ -398,7 +384,7 @@ const options = { ...@@ -398,7 +384,7 @@ const options = {
}).catch((err) => { }).catch((err) => {
console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); console.log('CloseKVStore getKVStore err ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
console.log('closeKVStore e ' + e); console.log('closeKVStore e ' + e);
} }
``` ```
...@@ -418,7 +404,7 @@ Deletes a KV store. This API uses an asynchronous callback to return the result. ...@@ -418,7 +404,7 @@ Deletes a KV store. This API uses an asynchronous callback to return the result.
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| appId | string | Yes | Bundle name of the app that invokes 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 [MAX_STORE_ID_LENGTH](#constants).| | storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Example** **Example**
...@@ -514,7 +500,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) ...@@ -514,7 +500,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore)
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| appId | string | Yes | Bundle name of the app that invokes the KV store. | | appId | string | Yes | Bundle name of the app that invokes the KV store. |
| callback | AsyncCallback&lt;string[]&gt; | Yes |Callback used to return the KV store IDs obtained. | | callback | AsyncCallback&lt;string[]&gt; | Yes |Callback invoked to return the KV store IDs obtained. |
**Example** **Example**
...@@ -574,7 +560,7 @@ try { ...@@ -574,7 +560,7 @@ try {
on(event: 'distributedDataServiceDie', deathCallback: Callback&lt;void&gt;): void on(event: 'distributedDataServiceDie', deathCallback: Callback&lt;void&gt;): void
Subscribes to service status changes. Subscribes to service status changes. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -590,7 +576,6 @@ Subscribes to service status changes. ...@@ -590,7 +576,6 @@ Subscribes to service status changes.
```js ```js
let kvManager; let kvManager;
try { try {
console.log('KVManagerOn'); console.log('KVManagerOn');
const deathCallback = function () { const deathCallback = function () {
console.log('death callback call'); console.log('death callback call');
...@@ -606,7 +591,7 @@ try { ...@@ -606,7 +591,7 @@ try {
off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): void off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): void
Unsubscribes from service status changes. Unsubscribes from service status changes. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...@@ -615,7 +600,7 @@ Unsubscribes from service status changes. ...@@ -615,7 +600,7 @@ Unsubscribes from service status changes.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.| | event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.|
| deathCallback | Callback&lt;void&gt; | No | Callback used to return a service status change event.| | deathCallback | Callback&lt;void&gt; | No | Callback for the service status change event.|
**Example** **Example**
...@@ -666,16 +651,14 @@ Enumerates the KV store types. ...@@ -666,16 +651,14 @@ Enumerates the KV store types.
Enumerates the KV store security levels. Enumerates the KV store security levels.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
| Name | Value| Description | | Name | Value| Description |
| --- | ---- | ----------------------- | | --- | ---- | ----------------------- |
| NO_LEVEL | 0 | No security level is set for the KV store. | | NO_LEVEL | 0 | No security level is set for the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| S0 | 1 | The KV store security level is public.| | S0 | 1 | The KV store security level is public.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.| | S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.| | S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.| | S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.| | S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
## Constants ## Constants
...@@ -1025,7 +1008,7 @@ try { ...@@ -1025,7 +1008,7 @@ try {
}).catch((err) => { }).catch((err) => {
console.log('getResultSet failed: ' + err); console.log('getResultSet failed: ' + err);
}); });
const moved5 = resultSet.move(); const moved5 = resultSet.move(1);
console.log("move succeed:" + moved5); console.log("move succeed:" + moved5);
} catch (e) { } catch (e) {
console.log("move failed: " + e); console.log("move failed: " + e);
...@@ -1065,7 +1048,7 @@ try { ...@@ -1065,7 +1048,7 @@ try {
}).catch((err) => { }).catch((err) => {
console.log('getResultSet failed: ' + err); console.log('getResultSet failed: ' + err);
}); });
const moved6 = resultSet.moveToPosition(); const moved6 = resultSet.moveToPosition(1);
console.log("moveToPosition succeed: " + moved6); console.log("moveToPosition succeed: " + moved6);
} catch (e) { } catch (e) {
console.log("moveToPosition failed: " + e); console.log("moveToPosition failed: " + e);
...@@ -2156,7 +2139,7 @@ Adds a KV pair of the specified type to this KV store. This API uses an asynchro ...@@ -2156,7 +2139,7 @@ Adds a KV pair of the specified type to this KV store. This API uses an asynchro
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | | key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). |
| value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). | | value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). |
| callback | AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -2229,7 +2212,7 @@ Deletes a KV pair from this KV store. This API uses an asynchronous callback to ...@@ -2229,7 +2212,7 @@ Deletes a KV pair from this KV store. This API uses an asynchronous callback to
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | | key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). |
| callback | AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -2314,7 +2297,7 @@ Deletes KV pairs that meet the specified conditions. This API uses an asynchrono ...@@ -2314,7 +2297,7 @@ Deletes KV pairs that meet the specified conditions. This API uses an asynchrono
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |Conditions for deleting data. If this parameter is **null**, define the processing logic.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |Conditions for deleting data. If this parameter is **null**, define the processing logic.|
| callback | AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -2395,8 +2378,8 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu ...@@ -2395,8 +2378,8 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| file | string | Yes | Name of the database. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| | file | string | Yes | Name of the RDB store. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is the error object. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is the error object.|
**Example** **Example**
...@@ -2429,7 +2412,7 @@ Backs up an RDB store. This API uses a promise to return the result. ...@@ -2429,7 +2412,7 @@ Backs up an RDB store. This API uses a promise to return the result.
| Name| Type| Mandatory| Description | | Name| Type| Mandatory| Description |
| ------ | -------- | ---- | ------------------------------------------------------------ | | ------ | -------- | ---- | ------------------------------------------------------------ |
| file | string | Yes | Name of the database. This parameter cannot be empty and its length cannot exceed [MAX_KEY_LENGTH](#constants).| | file | string | Yes | Name of the RDB store. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).|
**Return value** **Return value**
...@@ -2467,7 +2450,7 @@ Restores an RDB store from a database file. This API uses an asynchronous callba ...@@ -2467,7 +2450,7 @@ Restores an RDB store from a database file. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| file | string | Yes | Name of the database file. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).| | file | string | Yes | Name of the database file. The value cannot be empty or exceed [MAX_KEY_LENGTH](#constants).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example** **Example**
...@@ -2600,7 +2583,7 @@ try { ...@@ -2600,7 +2583,7 @@ try {
on(event: 'dataChange', type: SubscribeType, listener: Callback&lt;ChangeNotification&gt;): void on(event: 'dataChange', type: SubscribeType, listener: Callback&lt;ChangeNotification&gt;): void
Subscribes to data changes of the specified type. Subscribes to data changes of the specified type. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2610,7 +2593,7 @@ Subscribes to data changes of the specified type. ...@@ -2610,7 +2593,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. | | 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. | | type |[SubscribeType](#subscribetype) | Yes |Type of data change. |
| listener |Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes |Callback used to return a data change event.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; | Yes |Callback invoked to return a data change event.|
**Example** **Example**
...@@ -2626,7 +2609,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun ...@@ -2626,7 +2609,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Subscribes to synchronization complete events. Subscribes to synchronization complete events. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2635,7 +2618,7 @@ Subscribes to synchronization complete events. ...@@ -2635,7 +2618,7 @@ Subscribes to synchronization complete events.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates a synchronization complete event. | | event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates a synchronization complete event. |
| syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | Yes |Callback used to return a synchronization complete event. | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | Yes |Callback invoked to return a synchronization complete event.|
**Example** **Example**
...@@ -2650,7 +2633,7 @@ kvStore.on('syncComplete', function (data) { ...@@ -2650,7 +2633,7 @@ kvStore.on('syncComplete', function (data) {
off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void
Unsubscribes from data changes. Unsubscribes from data changes. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2659,7 +2642,7 @@ Unsubscribes from data changes. ...@@ -2659,7 +2642,7 @@ Unsubscribes from data changes.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. | | event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. |
| listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback used to return a data change event.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
**Example** **Example**
...@@ -2686,7 +2669,7 @@ class KvstoreModel { ...@@ -2686,7 +2669,7 @@ class KvstoreModel {
off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Unsubscribes from data changes. This API returns the result synchronously. Unsubscribes from the synchronization complete events. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2695,7 +2678,7 @@ Unsubscribes from data changes. This API returns the result synchronously. ...@@ -2695,7 +2678,7 @@ Unsubscribes from data changes. This API returns the result synchronously.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. | | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. |
| syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | No |Callback used to return a synchronization complete event. | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | No |Callback for the synchronization complete event. |
**Example** **Example**
...@@ -2732,7 +2715,7 @@ Inserts KV pairs in batches to this KV store. This API uses an asynchronous call ...@@ -2732,7 +2715,7 @@ Inserts KV pairs in batches to this KV store. This API uses an asynchronous call
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. | | entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. |
| callback |Asyncallback&lt;void&gt; |Yes |Callback used to return the result.| | callback |Asyncallback&lt;void&gt; |Yes |Callback invoked to return the result.|
**Example** **Example**
...@@ -2835,7 +2818,7 @@ Writes data to this KV store. This API uses an asynchronous callback to return ...@@ -2835,7 +2818,7 @@ Writes data to this KV store. This API uses an asynchronous callback to return
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| value |Array&lt;[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)&gt; | Yes |Data to write. | | value |Array&lt;[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)&gt; | Yes |Data to write. |
| callback |Asyncallback&lt;void&gt; |Yes |Callback used to return the result.| | callback |Asyncallback&lt;void&gt; |Yes |Callback invoked to return the result.|
**Example** **Example**
...@@ -2921,7 +2904,7 @@ Deletes KV pairs in batches from this KV store. This API uses an asynchronous ca ...@@ -2921,7 +2904,7 @@ Deletes KV pairs in batches from this KV store. This API uses an asynchronous ca
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| keys |string[] | Yes |KV pairs to delete in batches. | | keys |string[] | Yes |KV pairs to delete in batches. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3023,7 +3006,7 @@ Starts the transaction in this KV store. This API uses an asynchronous callback ...@@ -3023,7 +3006,7 @@ Starts the transaction in this KV store. This API uses an asynchronous callback
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3110,7 +3093,7 @@ Commits the transaction in this KV store. This API uses an asynchronous callback ...@@ -3110,7 +3093,7 @@ Commits the transaction in this KV store. This API uses an asynchronous callback
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3172,7 +3155,7 @@ Rolls back the transaction in this KV store. This API uses an asynchronous callb ...@@ -3172,7 +3155,7 @@ Rolls back the transaction in this KV store. This API uses an asynchronous callb
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3235,7 +3218,7 @@ Sets data synchronization, which can be enabled or disabled. This API uses an as ...@@ -3235,7 +3218,7 @@ Sets data synchronization, which can be enabled or disabled. This API uses an as
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| enabled |boolean | Yes |Whether to enable data synchronization. The value **true** means to enable data synchronization, and **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&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3305,7 +3288,7 @@ Sets the data synchronization range. This API uses an asynchronous callback to r ...@@ -3305,7 +3288,7 @@ Sets the data synchronization range. This API uses an asynchronous callback to r
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| localLabels |string[] | Yes |Synchronization labels set for the local device. | | localLabels |string[] | Yes |Synchronization labels set for the local device. |
| remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. | | remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -3632,7 +3615,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an ...@@ -3632,7 +3615,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| query |[Query](#query8) | Yes |Key prefix to match. | | query |[Query](#query8) | Yes |Key prefix to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback used to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. |
**Example** **Example**
...@@ -4033,7 +4016,7 @@ Closes the **KvStoreResultSet** object obtained by [SingleKvStore.getResultSet]( ...@@ -4033,7 +4016,7 @@ Closes the **KvStoreResultSet** object obtained by [SingleKvStore.getResultSet](
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -4205,7 +4188,7 @@ Deletes data of a device. This API uses an asynchronous callback to return the r ...@@ -4205,7 +4188,7 @@ Deletes data of a device. This API uses an asynchronous callback to return the r
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -4287,7 +4270,7 @@ try { ...@@ -4287,7 +4270,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Subscribes to synchronization complete events. Subscribes to synchronization complete events. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -4323,7 +4306,7 @@ try { ...@@ -4323,7 +4306,7 @@ try {
off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Unsubscribes from synchronization complete events. Unsubscribes from synchronization complete events. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -4332,7 +4315,7 @@ Unsubscribes from synchronization complete events. ...@@ -4332,7 +4315,7 @@ Unsubscribes from synchronization complete events.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. | | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event. |
| syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | No |Callback used to return a synchronization complete event. | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | No |Callback for the synchronization complete event. |
**Example** **Example**
...@@ -4394,7 +4377,7 @@ Unsubscribes from data changes. This API returns the result synchronously. ...@@ -4394,7 +4377,7 @@ Unsubscribes from data changes. This API returns the result synchronously.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. | | event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. |
| listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback used to return a data change event.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
**Example** **Example**
...@@ -4421,7 +4404,7 @@ class KvstoreModel { ...@@ -4421,7 +4404,7 @@ class KvstoreModel {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 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. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4445,7 +4428,7 @@ kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); ...@@ -4445,7 +4428,7 @@ kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000);
### sync<sup>9+</sup> ### sync<sup>9+</sup>
sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. This API returns the result synchronously. 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. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4497,7 +4480,7 @@ Sets the default delay allowed for KV store synchronization. This API uses an as ...@@ -4497,7 +4480,7 @@ Sets the default delay allowed for KV store synchronization. This API uses an as
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| defaultAllowedDelayMs |number | Yes |Default delay allowed for database synchronization, in ms. | | defaultAllowedDelayMs |number | Yes |Default delay allowed for database synchronization, in ms. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -4634,7 +4617,7 @@ Obtains a string value that matches the specified device ID and key. This API us ...@@ -4634,7 +4617,7 @@ Obtains a string value that matches the specified device ID and key. This API us
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| key |string | Yes |Key to match. | | key |string | Yes |Key to match. |
| callback |AsyncCallback&lt;boolean\|string\|number\|Uint8Array&gt; | Yes |Callback used to return the value obtained. | | callback |AsyncCallback&lt;boolean\|string\|number\|Uint8Array&gt; | Yes |Callback invoked to return the value obtained. |
**Example** **Example**
...@@ -4713,7 +4696,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API ...@@ -4713,7 +4696,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| keyPrefix |string | Yes |Key prefix to match. | | keyPrefix |string | Yes |Key prefix to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback used to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. |
**Example** **Example**
...@@ -4819,7 +4802,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an ...@@ -4819,7 +4802,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| query |[Query](#query8) | Yes |**Query** object to match. | | query |[Query](#query8) | Yes |**Query** object to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback used to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. |
**Example** **Example**
...@@ -5355,7 +5338,7 @@ Closes the **KvStoreResultSet** object obtained by [DeviceKVStore.getResultSet]( ...@@ -5355,7 +5338,7 @@ Closes the **KvStoreResultSet** object obtained by [DeviceKVStore.getResultSet](
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| resultSet |[KvStoreResultSet](#getresultset8) | Yes |**KvStoreResultSet** object to close. | | resultSet |[KvStoreResultSet](#getresultset8) | Yes |**KvStoreResultSet** object to close. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -5634,7 +5617,7 @@ Deletes data of the specified device from this KV store. This API uses an asynch ...@@ -5634,7 +5617,7 @@ Deletes data of the specified device from this KV store. This API uses an asynch
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. | | callback |AsyncCallback&lt;void&gt; | Yes |Callback invoked to return the result. |
**Example** **Example**
...@@ -5716,7 +5699,7 @@ try { ...@@ -5716,7 +5699,7 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 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. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -5755,7 +5738,7 @@ try { ...@@ -5755,7 +5738,7 @@ try {
sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. This API returns the result synchronously. 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. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -5797,7 +5780,7 @@ try { ...@@ -5797,7 +5780,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Subscribes to synchronization complete events. Subscribes to synchronization complete events. This API returns the result synchronously.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -5842,7 +5825,7 @@ Unsubscribes from synchronization complete events. This API returns the result s ...@@ -5842,7 +5825,7 @@ Unsubscribes from synchronization complete events. This API returns the result s
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.|
| syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | No |Callback used to return a synchronization complete event. | | syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | No |Callback for the synchronization complete event. |
**Example** **Example**
...@@ -5904,7 +5887,7 @@ Unsubscribes from data changes. This API returns the result synchronously. ...@@ -5904,7 +5887,7 @@ Unsubscribes from data changes. This API returns the result synchronously.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. | | event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates a data change event. |
| listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback used to return a data change event.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
**Example** **Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册