提交 de2e08f9 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 0368e671
...@@ -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'
......
...@@ -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.
先完成此消息的编辑!
想要评论请 注册