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

!7572 [翻译完成】#I5JBOL

Merge pull request !7572 from Annie_wang/PR7274B
# Value Bucket # Value Bucket
The **ValueBucket** holds data in key-value (KV) pairs. You can use it to insert data into a database. The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
>**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.
...@@ -20,7 +20,7 @@ Enumerates the value types allowed by the database. ...@@ -20,7 +20,7 @@ Enumerates the value types allowed by the database.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string.| | string | The value is a string.|
...@@ -28,10 +28,10 @@ Enumerates the value types allowed by the database. ...@@ -28,10 +28,10 @@ Enumerates the value types allowed by the database.
## ValuesBucket ## ValuesBucket
Holds a set of KV pairs. Defines the types of the key and value in a KV pair.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Type | Mandatory| Description | | Key Type | Value Type |
| ------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | ------------- | --------------------------------------------- |
| [key: string] | [ValueType](#valuetype)\| Uint8Array \| null | Yes | KV pairs in a **ValuesBucket**. The key is of the string type. The value can be a number, string, Boolean value, Unit8Array, or **null**.| | string | [ValueType](#valuetype)\| Uint8Array \| null |
...@@ -789,7 +789,7 @@ Enumerates the value types. ...@@ -789,7 +789,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
...@@ -681,7 +681,7 @@ Enumerates the value types. ...@@ -681,7 +681,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Description | | Type | Description |
| -------------- | ------------------------------ | | -------------- | ------------------------------ |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
...@@ -781,13 +781,6 @@ Sets the **RdbPredicates** to filter out duplicate records. ...@@ -781,13 +781,6 @@ Sets the **RdbPredicates** to filter out duplicate records.
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME") predicates.equalTo("NAME", "Rose").distinct("NAME")
let promise = rdbStore.query(predicates, ["NAME"])
promise.then((resultSet) => {
console.log("ResultSet column names: " + resultSet.columnNames)
console.log("ResultSet column count: " + resultSet.columnCount)
}).catch((err) => {
console.log("Query err.")
})
``` ```
...@@ -1133,7 +1126,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { ...@@ -1133,7 +1126,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) {
``` ```
### update<sup>9+</sup> ### update<sup>9+</sup>
update(table: string, values: ValuesBucket, predicates: DataSharePredicates):Promise&lt;number&gt; update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
...@@ -1215,7 +1208,7 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. ...@@ -1215,7 +1208,7 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the number of rows updated.| | Promise&lt;number&gt; | Promise used to return the number of rows updated.|
**Example** **Example**
```js ```js
...@@ -1231,7 +1224,7 @@ promise.then((rows) => { ...@@ -1231,7 +1224,7 @@ promise.then((rows) => {
### delete<sup>9+</sup> ### delete<sup>9+</sup>
delete(table: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
...@@ -1275,7 +1268,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1275,7 +1268,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the number of rows updated.| | Promise&lt;number&gt; | Promise used to return the number of rows updated.|
**Example** **Example**
```js ```js
...@@ -1354,7 +1347,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro ...@@ -1354,7 +1347,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro
### query<sup>9+</sup> ### query<sup>9+</sup>
query(predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
Queries data in the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Queries data in the RDB store based on specified conditions. This API uses an asynchronous callback to return the result.
...@@ -1363,6 +1356,7 @@ Queries data in the RDB store based on specified conditions. This API uses an as ...@@ -1363,6 +1356,7 @@ Queries data in the RDB store based on specified conditions. This API uses an as
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
| columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
| callback | AsyncCallback&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
...@@ -1384,7 +1378,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], ...@@ -1384,7 +1378,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"],
### query<sup>9+</sup> ### query<sup>9+</sup>
query(predicates: DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt; query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
Queries data in the RDB store based on specified conditions. This API uses a promise to return the result. Queries data in the RDB store based on specified conditions. This API uses a promise to return the result.
...@@ -1393,6 +1387,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro ...@@ -1393,6 +1387,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
| columns | Array&lt;string&gt; | No| Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
...@@ -1591,7 +1586,7 @@ rdbStore.commit() ...@@ -1591,7 +1586,7 @@ rdbStore.commit()
### rollBack<sup>8+</sup> ### rollBack<sup>8+</sup>
rollBack():void; rollBack():void
Rolls back the SQL statements that have been executed. Rolls back the SQL statements that have been executed.
...@@ -1997,7 +1992,7 @@ Defines the data types allowed. ...@@ -1997,7 +1992,7 @@ Defines the data types allowed.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Number.| | number | Number.|
| string | String.| | string | String.|
...@@ -2006,14 +2001,13 @@ Defines the data types allowed. ...@@ -2006,14 +2001,13 @@ Defines the data types allowed.
## ValuesBucket ## ValuesBucket
Defines a bucket to store key-value pairs. Defines the types of the key and value in a KV pair.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Type| Mandatory| Description| | Key Type| Value Type|
| -------- | -------- | -------- | -------- | | -------- | -------- |
| [key:&nbsp;string] | [ValueType](#valuetype)\|&nbsp;Uint8Array&nbsp;\|&nbsp;null | Yes| Defines a bucket to store key-value pairs.| | string | [ValueType](#valuetype)\|&nbsp;Uint8Array&nbsp;\|&nbsp;null |
## SyncMode<sup>8+</sup> ## SyncMode<sup>8+</sup>
......
...@@ -793,7 +793,7 @@ Enumerates the value types. ...@@ -793,7 +793,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册