提交 b48b9ffe 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 0337b2b7
...@@ -9,7 +9,7 @@ This module provides the following functions: ...@@ -9,7 +9,7 @@ This module provides the following functions:
- [Query<sup>8+</sup>](#query8): provides methods to query data from the database through a **Query** instance by using predicates. - [Query<sup>8+</sup>](#query8): provides methods to query data from the database through a **Query** instance by using predicates.
- [KVStore](#kvstore): provides methods to add data, delete data, and observe data changes and data synchronization through a **KVStore** instance. - [KVStore](#kvstore): provides methods to add data, delete data, and observe data changes and data synchronization through a **KVStore** instance.
- [SingleKVStore](#singlekvstore): provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore), and data is not distinguished by device. - [SingleKVStore](#singlekvstore): provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore), and data is not distinguished by device.
- [DeviceKVStore<sup>8+</sup> ](#devicekvstore8): provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore), and data is distinguished by device. - [DeviceKVStore<sup>8+</sup>](#devicekvstore8): provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore), and data is distinguished by device.
>**NOTE** >**NOTE**
> >
...@@ -128,8 +128,8 @@ Defines user information. ...@@ -128,8 +128,8 @@ Defines user information.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ----- | ------ |------ | ------ | | ----- | ------ |------ | ------ |
| userId | string | No | User ID.| | userId | string | No | User ID. The default value is **0**.|
| userType | [UserType](#usertype) | No | User type.| | userType | [UserType](#usertype) | No | User type. The default value is **0**.|
## UserType ## UserType
...@@ -267,7 +267,7 @@ const options = { ...@@ -267,7 +267,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedData.SecurityLevel.S2, securityLevel: distributedData.SecurityLevel.S2,
} }
try { try {
...@@ -317,7 +317,7 @@ const options = { ...@@ -317,7 +317,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedData.SecurityLevel.S2, securityLevel: distributedData.SecurityLevel.S2,
} }
try { try {
...@@ -365,7 +365,7 @@ const options = { ...@@ -365,7 +365,7 @@ const options = {
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema : undefined,
securityLevel : distributedData.SecurityLevel.S2, securityLevel : distributedData.SecurityLevel.S2,
} }
try { try {
...@@ -414,7 +414,7 @@ const options = { ...@@ -414,7 +414,7 @@ const options = {
backup : false, backup : false,
autoSync : true, autoSync : true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '', schema : undefined,
securityLevel : distributedData.SecurityLevel.S2, securityLevel : distributedData.SecurityLevel.S2,
} }
try { try {
...@@ -548,7 +548,7 @@ Unsubscribes from service status changes. ...@@ -548,7 +548,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 for the service status change event.| | deathCallback | Callback&lt;void&gt; | No | Callback for the service status change event. If the callback is not specified, all subscriptions to the service status change event are canceled.|
**Example** **Example**
...@@ -574,13 +574,13 @@ Provides KV store configuration. ...@@ -574,13 +574,13 @@ Provides KV store configuration.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ------ | -------------------| | ----- | ------ | ------ | -------------------|
| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | createIfMissing | boolean | No| Whether to create a KV store if the database file does not exist. The default value is **true**, which means to create a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | No|Whether to encrypt the KV store. The default value is **false**, which means the KV store is not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| backup | boolean | No|Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | backup | boolean | No|Whether to back up the KV store. The default value is **true**, which means to back up the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| autoSync | boolean | No|Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | | autoSync | boolean | No|Whether to automatically synchronize database files. The default value is **false**, which means the database files are manually synchronized.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC |
| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. The default value is **DEVICE_COLLABORATION**, which indicates a device KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | securityLevel | [SecurityLevel](#securitylevel) | Yes|Security level (S1 to S4) of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| | schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in the KV store. The default value is **undefined**, which means no schema is used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
## KVStoreType ## KVStoreType
...@@ -601,12 +601,12 @@ Enumerates the KV store security levels. ...@@ -601,12 +601,12 @@ Enumerates the KV store security levels.
| Name | Value| Description | | Name | Value| Description |
| --- | ---- | ----------------------- | | --- | ---- | ----------------------- |
| NO_LEVEL | 0 | No security level is set for the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | | NO_LEVEL | 0 | No security level is set for the KV store (deprecated).<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| S0 | 1 | The KV store security level is public.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | S0 | 1 | The KV store security level is public (deprecated).<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.<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. 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.<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. 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.<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. 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.<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. For example, a KV store that contains information such as authentication credentials and financial data.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
## Constants ## Constants
...@@ -1686,7 +1686,7 @@ Creates a **Query** object with the AND condition. ...@@ -1686,7 +1686,7 @@ Creates a **Query** object with the AND condition.
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
| [Query](#query8) |**Query** object Created.| | [Query](#query8) |**Query** object created.|
**Example** **Example**
...@@ -1716,7 +1716,7 @@ Creates a **Query** object with the OR condition. ...@@ -1716,7 +1716,7 @@ Creates a **Query** object with the OR condition.
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
| [Query](#query8) |**Query** object Created.| | [Query](#query8) |**Query** object created.|
**Example** **Example**
...@@ -2295,7 +2295,7 @@ Unsubscribes from data changes. ...@@ -2295,7 +2295,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 for the data change event.| | listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event are canceled.|
...@@ -2333,7 +2333,7 @@ Unsubscribes from synchronization complete events. ...@@ -2333,7 +2333,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 for the synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event are canceled.|
**Example** **Example**
...@@ -3895,7 +3895,7 @@ Unsubscribes from data changes. ...@@ -3895,7 +3895,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 for the data change event.| | listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event are canceled.|
**Example** **Example**
...@@ -3931,7 +3931,7 @@ Unsubscribes from synchronization complete events. ...@@ -3931,7 +3931,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 for the synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event are canceled. |
**Example** **Example**
...@@ -5258,7 +5258,7 @@ Synchronizes the KV store manually. ...@@ -5258,7 +5258,7 @@ Synchronizes the KV store manually.
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceIds |string[] | Yes |IDs of the devices to be synchronized.| | deviceIds |string[] | Yes |IDs of the devices to be synchronized.|
| mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | | mode |[SyncMode](#syncmode) | Yes |Synchronization mode. |
| delayMs |number | No |Allowed synchronization delay time, in ms. | | delayMs |number | No |Allowed synchronization delay time, in ms. The default value is **0**. |
**Example** **Example**
...@@ -5373,7 +5373,7 @@ Unsubscribes from data changes. ...@@ -5373,7 +5373,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 for the data change event.| | listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event are canceled.|
**Example** **Example**
...@@ -5409,7 +5409,7 @@ Unsubscribes from synchronization complete events. ...@@ -5409,7 +5409,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 for the synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event are canceled. |
**Example** **Example**
......
...@@ -12,8 +12,8 @@ The **distributedKVStore** module provides the following functions: ...@@ -12,8 +12,8 @@ The **distributedKVStore** module provides the following functions:
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> <br>All the APIs that need to obtain **deviceId** in this module are available only to system applications. > - All the APIs that need to obtain **deviceId** in this module are available only to system applications.
## Modules to Import ## Modules to Import
...@@ -41,7 +41,7 @@ Provides constants of the distributed KV store. ...@@ -41,7 +41,7 @@ Provides constants of the distributed KV store.
| Name | Value | Description | | Name | Value | Description |
| --------------------- | ------- | --------------------------------------- | | --------------------- | ------- | --------------------------------------- |
| MAX_KEY_LENGTH | 1024 | Maximum length of a key in a distributed KV store, in bytes. | | MAX_KEY_LENGTH | 1024 | Maximum length of a key in a distributed KV store, in bytes. |
| MAX_VALUE_LENGTH | 4194303 | Maximum length of a value in a distributed KV store, in bytes. | | MAX_VALUE_LENGTH | 4194303 | Maximum length of a value in a distributed KV store, in bytes.|
| MAX_KEY_LENGTH_DEVICE | 896 | Maximum length of a key in a device KV store, in bytes.| | MAX_KEY_LENGTH_DEVICE | 896 | Maximum length of a key in a device KV store, in bytes.|
| MAX_STORE_ID_LENGTH | 128 | Maximum length of a KV store ID, in bytes. | | MAX_STORE_ID_LENGTH | 128 | Maximum length of a KV store ID, in bytes. |
| MAX_QUERY_LENGTH | 512000 | Maximum query length, in bytes. | | MAX_QUERY_LENGTH | 512000 | Maximum query length, in bytes. |
...@@ -127,7 +127,7 @@ Enumerates the distributed KV store types. ...@@ -127,7 +127,7 @@ Enumerates the distributed KV store types.
| Name | Description | | Name | Description |
| -------------------- | ------------------------------------------------------------ | | -------------------- | ------------------------------------------------------------ |
| DEVICE_COLLABORATION | Device KV store.<br>The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| | DEVICE_COLLABORATION | Device KV store.<br>The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| SINGLE_VERSION | Single KV store.<br>The single KV store does not differentiate data by device. If entries with the same key are modified on different devices, the value will be overwritten.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | SINGLE_VERSION | Single KV store.<br>The single KV store does not differentiate data by device. If entries with the same key are modified on different devices, the value will be overwritten.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
## SecurityLevel ## SecurityLevel
...@@ -137,11 +137,11 @@ Enumerates the KV store security levels. ...@@ -137,11 +137,11 @@ Enumerates the KV store security levels.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
| Name | Description | | Name | Description |
| ---: | ------------------------------------------------------------ | | -------: | ------------------------------------------------------------ |
| S1 | Low security level. Disclosure, tampering, corruption, or loss of the data may cause minor impact on an individual or group.<br>Examples: gender and nationality information, and user application records | | S1 | Low security level. Disclosure, tampering, corruption, or loss of the data may cause minor impact on an individual or group.<br>Examples: gender and nationality information, and user application records|
| S2 | Medium security level. Disclosure, tampering, corruption, or loss of the data may cause major impact on an individual or group.<br>Examples: mailing addresses and nicknames of individuals | | S2 | Medium security level. Disclosure, tampering, corruption, or loss of the data may cause major impact on an individual or group.<br>Examples: mailing addresses and nicknames of individuals|
| S3 | High security level. Disclosure, tampering, corruption, or loss of the data may cause critical impact on an individual or group.<br>Examples: real-time precise positioning information and movement trajectory | | S3 | High security level. Disclosure, tampering, corruption, or loss of the data may cause critical impact on an individual or group.<br>Examples: real-time precise positioning information and movement trajectory |
| S4 | Critical security level. Disclosure, tampering, corruption, or loss of the data may cause significant adverse impact on an individual or group.<br>Examples: political opinions, religious and philosophical belief, trade union membership, genetic data, biological information, health and sexual life status, sexual orientation, device authentication, and personal credit card information | | S4 | Critical security level. Disclosure, tampering, corruption, or loss of the data may cause significant adverse impact on an individual or group.<br>Examples: political opinions, religious and philosophical belief, trade union membership, genetic data, biological information, health and sexual life status, sexual orientation, device authentication, and personal credit card information|
## Options ## Options
...@@ -149,13 +149,13 @@ Provides KV store configuration. ...@@ -149,13 +149,13 @@ Provides KV store configuration.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | -------------- | ---- | -------------------------| | --------------- | -------------- | ---- | -------------------------|
| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | createIfMissing | boolean | No | Whether to create a KV store if the database file does not exist. The default value is **true**, which means to create a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| encrypt | boolean | No | Whether to encrypt the KV store. By default, KV stores are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | No | Whether to encrypt the KV store. The default value is **false**, which means the KV store is not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| backup | boolean | No | Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | backup | boolean | No | Whether to back up the KV store. The default value is **true**, which means to back up the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| autoSync | boolean | No | Whether to automatically synchronize the KV store data. The value **true** means to automatically synchronize the KV store data; the value **false** (default) means the opposite.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | | autoSync | boolean | No | Whether to automatically synchronize database files. The default value is **false**, which means the database files are manually synchronized.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC|
| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. The default value is **DEVICE_COLLABORATION**, which indicates a device KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | securityLevel | [SecurityLevel](#securitylevel) | Yes | Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| | schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. The default value is **undefined**, which means no schema is used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
## Schema ## Schema
...@@ -166,7 +166,7 @@ Defines the schema of a KV store. You can create a **Schema** object and place i ...@@ -166,7 +166,7 @@ Defines the schema of a KV store. You can create a **Schema** object and place i
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------- | ----------------------- | ---- | ---- | -------------------------- | | ------- | ----------------------- | ---- | ---- | -------------------------- |
| root | [FieldNode](#fieldnode) | Yes | Yes | JSON root object. | | root | [FieldNode](#fieldnode) | Yes | Yes | JSON root object. |
| indexes | Array\<string> | Yes | Yes | Array of strings in JSON format. | | indexes | Array\<string> | Yes | Yes | String array in JSON format.|
| mode | number | Yes | Yes | Schema mode. | | mode | number | Yes | Yes | Schema mode. |
| skip | number | Yes | Yes | Size of a skip of the schema. | | skip | number | Yes | Yes | Size of a skip of the schema. |
...@@ -444,7 +444,7 @@ const options = { ...@@ -444,7 +444,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedKVStore.SecurityLevel.S2, securityLevel: distributedKVStore.SecurityLevel.S2,
} }
try { try {
...@@ -500,7 +500,7 @@ const options = { ...@@ -500,7 +500,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedKVStore.SecurityLevel.S2, securityLevel: distributedKVStore.SecurityLevel.S2,
} }
try { try {
...@@ -555,7 +555,7 @@ const options = { ...@@ -555,7 +555,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedKVStore.SecurityLevel.S2, securityLevel: distributedKVStore.SecurityLevel.S2,
} }
try { try {
...@@ -619,7 +619,7 @@ const options = { ...@@ -619,7 +619,7 @@ const options = {
backup: false, backup: false,
autoSync: true, autoSync: true,
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
schema: '', schema: undefined,
securityLevel: distributedKVStore.SecurityLevel.S2, securityLevel: distributedKVStore.SecurityLevel.S2,
} }
try { try {
...@@ -645,7 +645,7 @@ try { ...@@ -645,7 +645,7 @@ try {
getAllKVStoreId(appId: string, callback: AsyncCallback&lt;string[]&gt;): void getAllKVStoreId(appId: string, callback: AsyncCallback&lt;string[]&gt;): void
Obtains IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses an asynchronous callback to return the result. Obtains the IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -677,7 +677,7 @@ try { ...@@ -677,7 +677,7 @@ try {
getAllKVStoreId(appId: string): Promise&lt;string[]&gt; getAllKVStoreId(appId: string): Promise&lt;string[]&gt;
Obtains IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses a promise to return the result. Obtains the IDs of all distributed KV stores that are created by [getKVStore](#getkvstore) and have not been deleted by [deleteKVStore](#deletekvstore). This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -751,7 +751,7 @@ Unsubscribes from service status changes. The **deathCallback** parameter must b ...@@ -751,7 +751,7 @@ Unsubscribes from service status changes. The **deathCallback** parameter must b
| 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 for the service status change event. If this parameter is not specified, all deathCallback subscriptions will be canceled. | | deathCallback | Callback&lt;void&gt; | No | Callback for the service status change event. If this parameter is not specified, all subscriptions to the service status change event are canceled. |
**Example** **Example**
...@@ -4562,7 +4562,7 @@ Synchronizes the KV store manually. For details about the synchronization modes ...@@ -4562,7 +4562,7 @@ Synchronizes the KV store manually. For details about the synchronization modes
| --------- | --------------------- | ---- | ---------------------------------------------- | | --------- | --------------------- | ---- | ---------------------------------------------- |
| deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.|
| mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. |
| delayMs | number | No | Allowed synchronization delay time, in ms. | | delayMs | number | No | Allowed synchronization delay time, in ms. The default value is **0**. |
**Error codes** **Error codes**
...@@ -4632,7 +4632,7 @@ Synchronizes the KV store manually. This API returns the result synchronously. F ...@@ -4632,7 +4632,7 @@ Synchronizes the KV store manually. This API returns the result synchronously. F
| deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.|
| mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. |
| query | [Query](#query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| delayMs | number | No | Allowed synchronization delay time, in ms. | | delayMs | number | No | Allowed synchronization delay time, in ms. The default value is **0**.|
**Error codes** **Error codes**
...@@ -4769,7 +4769,7 @@ Unsubscribes from data changes. ...@@ -4769,7 +4769,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 for the data change event. | | listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event are canceled.|
**Error codes** **Error codes**
...@@ -4822,7 +4822,7 @@ Unsubscribes from synchronization complete events. ...@@ -4822,7 +4822,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 for the synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event are canceled. |
**Example** **Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册