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

!3985 #I56515完成,请审批

Merge pull request !3985 from Annie_wang/PR3723
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
``` ```
...@@ -25,11 +25,11 @@ Creates a distributed data object. ...@@ -25,11 +25,11 @@ Creates a distributed data object.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| source | object | Yes| Attribute of the distributed data object to create.| | source | object | Yes| Attribute of the distributed data object to create.|
**Return Value** **Return Value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [DistributedObject](#distributedobject) | Distributed data object created.| | [DistributedObject](#distributedobject) | Distributed data object created.|
**Example** **Example**
```js ```js
...@@ -83,7 +83,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -83,7 +83,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. | | boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
**Example** **Example**
```js ```js
...@@ -171,8 +171,6 @@ Subscribes to the status changes (online or offline) of this distributed data ob ...@@ -171,8 +171,6 @@ Subscribes to the status changes (online or offline) of this distributed data ob
| type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.| | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the online or offline status.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the network ID of the device.<br>**status** indicates the status, which can be online or offline.| | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the online or offline status.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the network ID of the device.<br>**status** indicates the status, which can be online or offline.|
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject'
......
...@@ -32,14 +32,14 @@ Reads a preference persistence file and loads data to the **Preferences** instan ...@@ -32,14 +32,14 @@ Reads a preference persistence file and loads data to the **Preferences** instan
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -77,18 +77,18 @@ Reads a preference persistence file and loads data to the **Preferences** instan ...@@ -77,18 +77,18 @@ Reads a preference persistence file and loads data to the **Preferences** instan
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[Preferences](#preferences)&gt; | Promise used to return the execution result.| | Promise&lt;[Preferences](#preferences)&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -126,14 +126,14 @@ Once a preference persistence file is deleted, the **Preferences** instance cann ...@@ -126,14 +126,14 @@ Once a preference persistence file is deleted, the **Preferences** instance cann
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -159,18 +159,18 @@ Once a preference persistence file is deleted, the **Preferences** instance cann ...@@ -159,18 +159,18 @@ Once a preference persistence file is deleted, the **Preferences** instance cann
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -196,14 +196,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us ...@@ -196,14 +196,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -230,18 +230,18 @@ When a **Preferences** singleton instance is removed, this instance cannot be us ...@@ -230,18 +230,18 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.| | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -270,14 +270,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def ...@@ -270,14 +270,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to obtain. It cannot be empty.| | key | string | Yes| Key of the data to obtain. It cannot be empty.|
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
| callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -308,18 +308,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def ...@@ -308,18 +308,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to obtain. It cannot be empty.| | key | string | Yes| Key of the data to obtain. It cannot be empty.|
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;ValueType&gt; | Promise used to return the execution result.| | Promise&lt;ValueType&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -344,18 +344,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def ...@@ -344,18 +344,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def
put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
Obtain a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the execution result. Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the execution result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -382,22 +382,22 @@ Obtain a **Preferences** instance, writes data to the **Preferences** instance, ...@@ -382,22 +382,22 @@ Obtain a **Preferences** instance, writes data to the **Preferences** instance,
put(key: string, value: ValueType): Promise&lt;void&gt; put(key: string, value: ValueType): Promise&lt;void&gt;
Obtain a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses a promise to return the execution result. Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses a promise to return the execution result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.| | key | string | Yes| Key of the data. It cannot be empty.|
| value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -426,18 +426,18 @@ Checks whether the **Preferences** instance contains data with a given key. This ...@@ -426,18 +426,18 @@ Checks whether the **Preferences** instance contains data with a given key. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to check. It cannot be empty.| | key | string | Yes| Key of the data to check. It cannot be empty.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the execution result.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.| | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -472,17 +472,17 @@ Checks whether the **Preferences** instance contains data with a given key. This ...@@ -472,17 +472,17 @@ Checks whether the **Preferences** instance contains data with a given key. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to check. It cannot be empty.| | key | string | Yes| Key of the data to check. It cannot be empty.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the execution result.| | Promise&lt;boolean&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -515,13 +515,13 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi ...@@ -515,13 +515,13 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the KV pair to delete. It cannot be empty.| | key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -552,17 +552,17 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi ...@@ -552,17 +552,17 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the KV pair to delete. It cannot be empty.| | key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -591,12 +591,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod ...@@ -591,12 +591,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -627,12 +627,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod ...@@ -627,12 +627,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -661,12 +661,12 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call ...@@ -661,12 +661,12 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -697,12 +697,12 @@ Clears data of this **Preferences** instance. This API uses a promise to return ...@@ -697,12 +697,12 @@ Clears data of this **Preferences** instance. This API uses a promise to return
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -731,13 +731,13 @@ Subscribes to data changes. When the value of the subscribed key changes, a call ...@@ -731,13 +731,13 @@ Subscribes to data changes. When the value of the subscribed key changes, a call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string | Event type. The value **change** indicates data change events.|
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
...@@ -779,13 +779,13 @@ Unsubscribes from data changes. ...@@ -779,13 +779,13 @@ Unsubscribes from data changes.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
- Parameters **Parameters**
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string | Event type. The value **change** indicates data change events.|
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.|
- Example **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences' import data_preferences from '@ohos.data.preferences'
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
You need to use [RdbStore.query()](js-apis-data-rdb.md#query) to obtain the **resultSet** object. You need to use [RdbStore.query()](js-apis-data-rdb.md#query) to obtain the **resultSet** object.
``` ```js
import dataRdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("AGE", 18) predicates.equalTo("AGE", 18)
...@@ -18,10 +18,6 @@ promise.then((resultSet) => { ...@@ -18,10 +18,6 @@ promise.then((resultSet) => {
console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);}) console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);})
``` ```
## ResultSet ## ResultSet
Provides methods to access the result set, which is obtained by querying the relational database (RDB) store. Provides methods to access the result set, which is obtained by querying the relational database (RDB) store.
...@@ -52,18 +48,18 @@ Obtains the column index based on the column name. ...@@ -52,18 +48,18 @@ Obtains the column index based on the column name.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnName | string | Yes| Column name specified.| | columnName | string | Yes| Column name specified.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Index of the column obtained.| | number | Index of the column obtained.|
- Example **Example**
``` ```js
resultSet.goToFirstRow() resultSet.goToFirstRow()
const id = resultSet.getLong(resultSet.getColumnIndex("ID")) const id = resultSet.getLong(resultSet.getColumnIndex("ID"))
const name = resultSet.getString(resultSet.getColumnIndex("NAME")) const name = resultSet.getString(resultSet.getColumnIndex("NAME"))
...@@ -80,18 +76,18 @@ Obtains the column name based on the column index. ...@@ -80,18 +76,18 @@ Obtains the column name based on the column index.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Column index specified.| | columnIndex | number | Yes| Column index specified.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Column name obtained.| | string | Column name obtained.|
- Example **Example**
``` ```js
const id = resultSet.getColumnName(0) const id = resultSet.getColumnName(0)
const name = resultSet.getColumnName(1) const name = resultSet.getColumnName(1)
const age = resultSet.getColumnName(2) const age = resultSet.getColumnName(2)
...@@ -106,18 +102,18 @@ Moves the cursor to the row based on the specified offset. ...@@ -106,18 +102,18 @@ Moves the cursor to the row based on the specified offset.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| offset | number | Yes| Offset relative to the current position.| | offset | number | Yes| Offset relative to the current position.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgoto = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygoto = rdbStore.query(predicatesgoto, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoto.then((resultSet) { promisequerygoto.then((resultSet) {
...@@ -137,18 +133,18 @@ Moves the cursor to the specified row in the result set. ...@@ -137,18 +133,18 @@ Moves the cursor to the specified row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| position | number | Yes| Position to which the cursor is to be moved.| | position | number | Yes| Position to which the cursor is to be moved.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgotorow = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygotorow = rdbStore.query(predicatesgotorow, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygotorow.then((resultSet) { promisequerygotorow.then((resultSet) {
...@@ -169,13 +165,13 @@ Moves the cursor to the first row of the result set. ...@@ -169,13 +165,13 @@ Moves the cursor to the first row of the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgoFirst = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygoFirst = rdbStore.query(predicatesgoFirst, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoFirst.then((resultSet) { promisequerygoFirst.then((resultSet) {
...@@ -195,13 +191,13 @@ Moves the cursor to the last row of the result set. ...@@ -195,13 +191,13 @@ Moves the cursor to the last row of the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgoLast = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygoLast = rdbStore.query(predicatesgoLast, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoLast.then((resultSet) { promisequerygoLast.then((resultSet) {
...@@ -221,13 +217,13 @@ Moves the cursor to the next row in the result set. ...@@ -221,13 +217,13 @@ Moves the cursor to the next row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgoNext = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygoNext = rdbStore.query(predicatesgoNext, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoNext.then((resultSet) { promisequerygoNext.then((resultSet) {
...@@ -247,13 +243,13 @@ Moves the cursor to the previous row in the result set. ...@@ -247,13 +243,13 @@ Moves the cursor to the previous row in the result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example **Example**
``` ```js
let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesgoPrev = new dataRdb.RdbPredicates("EMPLOYEE")
let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promisequerygoPrev = rdbStore.query(predicatesgoPrev, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoPrev.then((resultSet) { promisequerygoPrev.then((resultSet) {
...@@ -273,18 +269,18 @@ Obtains the value in the specified column in the current row as a byte array. ...@@ -273,18 +269,18 @@ Obtains the value in the specified column in the current row as a byte array.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.| | columnIndex | number | Yes| Index of the specified column, starting from 0.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Uint8Array | Value in the specified column as a byte array.| | Uint8Array | Value in the specified column as a byte array.|
- Example **Example**
``` ```js
const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES")) const codes = resultSet.getBlob(resultSet.getColumnIndex("CODES"))
``` ```
...@@ -297,18 +293,18 @@ Obtains the value in the specified column in the current row as a string. ...@@ -297,18 +293,18 @@ Obtains the value in the specified column in the current row as a string.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.| | columnIndex | number | Yes| Index of the specified column, starting from 0.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Value in the specified column as a string.| | string | Value in the specified column as a string.|
- Example **Example**
``` ```js
const name = resultSet.getString(resultSet.getColumnIndex("NAME")) const name = resultSet.getString(resultSet.getColumnIndex("NAME"))
``` ```
...@@ -321,18 +317,18 @@ Obtains the value in the specified column in the current row as a Long. ...@@ -321,18 +317,18 @@ Obtains the value in the specified column in the current row as a Long.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.| | columnIndex | number | Yes| Index of the specified column, starting from 0.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Value in the specified column as a Long.| | number | Value in the specified column as a Long.|
- Example **Example**
``` ```js
const age = resultSet.getLong(resultSet.getColumnIndex("AGE")) const age = resultSet.getLong(resultSet.getColumnIndex("AGE"))
``` ```
...@@ -345,18 +341,18 @@ Obtains the value in the specified column in the current row as a double. ...@@ -345,18 +341,18 @@ Obtains the value in the specified column in the current row as a double.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.| | columnIndex | number | Yes| Index of the specified column, starting from 0.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Value in the specified column as a double.| | number | Value in the specified column as a double.|
- Example **Example**
``` ```js
const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")) const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"))
``` ```
...@@ -369,18 +365,18 @@ Checks whether the value in the specified column of the current row is null. ...@@ -369,18 +365,18 @@ Checks whether the value in the specified column of the current row is null.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| columnIndex | number | Yes| Index of the specified column, starting from 0.| | columnIndex | number | Yes| Index of the specified column, starting from 0.|
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the value is null; returns **false** otherwise.| | boolean | Returns **true** if the value is null; returns **false** otherwise.|
- Example **Example**
``` ```js
const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES")) const isColumnNull = resultSet.isColumnNull(resultSet.getColumnIndex("CODES"))
``` ```
...@@ -393,13 +389,13 @@ Closes this result set. ...@@ -393,13 +389,13 @@ Closes this result set.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
- Example **Example**
``` ```js
let predicatesclose = new dataRdb.RdbPredicates("EMPLOYEE") let predicatesClose = new dataRdb.RdbPredicates("EMPLOYEE")
let predicatesclose = rdbStore.query(predicatesclose, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promiseClose = rdbStore.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promisequerygoPrev.then((resultSet) { promiseClose.then((resultSet) {
resultSet.close() resultSet.close()
}).catch((err) => { }).catch((err) => {
console.log('query failed') console.log('Failed to close resultset')
}) })
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册