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

!9577 [翻译完成】#I5NNFM

Merge pull request !9577 from Annie_wang/PR8478
...@@ -36,9 +36,16 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul ...@@ -36,9 +36,16 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
**Example** **Example**
FA model:
```js ```js
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
// Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db"} const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) {
if (err) { if (err) {
console.info("Failed to get RdbStore, err: " + err) console.info("Failed to get RdbStore, err: " + err)
return return
...@@ -47,6 +54,28 @@ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { ...@@ -47,6 +54,28 @@ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
}) })
``` ```
Stage model:
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
// Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) {
if (err) {
console.info("Failed to get RdbStore, err: " + err)
return
}
console.log("Got RdbStore successfully.")
})
```
## data_rdb.getRdbStore ## data_rdb.getRdbStore
getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore>
...@@ -71,9 +100,38 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ...@@ -71,9 +100,38 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
**Example** **Example**
FA model:
```js ```js
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
// Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" } const STORE_CONFIG = { name: "RdbTest.db" }
let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1);
promise.then(async (rdbStore) => {
console.log("Got RdbStore successfully.")
}).catch((err) => {
console.log("Failed to get RdbStore, err: " + err)
})
```
Stage model:
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
// Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" }
let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1);
promise.then(async (rdbStore) => { promise.then(async (rdbStore) => {
console.log("Got RdbStore successfully.") console.log("Got RdbStore successfully.")
}).catch((err) => { }).catch((err) => {
...@@ -90,6 +148,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul ...@@ -90,6 +148,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
...@@ -97,8 +156,38 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul ...@@ -97,8 +156,38 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
**Example** **Example**
FA model:
```js ```js
data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
// Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) {
if (err) {
console.info("Failed to delete RdbStore, err: " + err)
return
}
console.log("Deleted RdbStore successfully.")
})
```
Stage model:
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
// Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) {
if (err) { if (err) {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
return return
...@@ -116,19 +205,29 @@ Deletes an RDB store. This API uses a promise to return the result. ...@@ -116,19 +205,29 @@ Deletes an RDB store. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).|
| name | string | Yes| Name of the RDB store to delete.| | name | string | Yes| Name of the RDB store to delete.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
FA model:
```js ```js
let promise = data_rdb.deleteRdbStore(this.context, "RdbTest.db") // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
// Call deleteRdbStore.
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
promise.then(()=>{ promise.then(()=>{
console.log("Deleted RdbStore successfully.") console.log("Deleted RdbStore successfully.")
}).catch((err) => { }).catch((err) => {
...@@ -136,6 +235,26 @@ promise.then(()=>{ ...@@ -136,6 +235,26 @@ promise.then(()=>{
}) })
``` ```
Stage model:
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
// Call deleteRdbStore.
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
promise.then(()=>{
console.log("Deleted RdbStore successfully.")
}).catch((err) => {
console.info("Failed to delete RdbStore, err: " + err)
})
```
## RdbPredicates ## RdbPredicates
...@@ -152,11 +271,13 @@ A constructor used to create an **RdbPredicates** object. ...@@ -152,11 +271,13 @@ A constructor used to create an **RdbPredicates** object.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Database table name.| | name | string | Yes| Database table name.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
``` ```
...@@ -166,21 +287,24 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE") ...@@ -166,21 +287,24 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
inDevices(devices: Array&lt;string&gt;): RdbPredicates inDevices(devices: Array&lt;string&gt;): RdbPredicates
Connects to the specified remote devices on the network during distributed database synchronization. Sets an **RdbPredicates** to specify the remote devices on the network to connect during distributed database synchronization.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| devices | Array&lt;string&gt; | Yes| IDs of the remote devices in the same network.| | devices | Array&lt;string&gt; | Yes| IDs of the remote devices in the same network.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.inDevices(['12345678abcde']) predicates.inDevices(['12345678abcde'])
...@@ -191,16 +315,18 @@ predicates.inDevices(['12345678abcde']) ...@@ -191,16 +315,18 @@ predicates.inDevices(['12345678abcde'])
inAllDevices(): RdbPredicates inAllDevices(): RdbPredicates
Connects to all remote devices on the network during distributed database synchronization. Sets an **RdbPredicates** to specify all remote devices on the network to connect during distributed database synchronization.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.inAllDevices() predicates.inAllDevices()
...@@ -216,17 +342,20 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -216,17 +342,20 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi") predicates.equalTo("NAME", "lisi")
...@@ -243,17 +372,20 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -243,17 +372,20 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notEqualTo("NAME", "lisi") predicates.notEqualTo("NAME", "lisi")
...@@ -270,11 +402,13 @@ Adds a left parenthesis to the **RdbPredicates**. ...@@ -270,11 +402,13 @@ Adds a left parenthesis to the **RdbPredicates**.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi") predicates.equalTo("NAME", "lisi")
...@@ -285,22 +419,22 @@ predicates.equalTo("NAME", "lisi") ...@@ -285,22 +419,22 @@ predicates.equalTo("NAME", "lisi")
.endWrap() .endWrap()
``` ```
### endWrap ### endWrap
endWrap(): RdbPredicates endWrap(): RdbPredicates
Adds a right parenthesis to the **RdbPredicates**. Adds a right parenthesis to the **RdbPredicates**.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi") predicates.equalTo("NAME", "lisi")
...@@ -311,22 +445,22 @@ predicates.equalTo("NAME", "lisi") ...@@ -311,22 +445,22 @@ predicates.equalTo("NAME", "lisi")
.endWrap() .endWrap()
``` ```
### or ### or
or(): RdbPredicates or(): RdbPredicates
Adds the OR condition to the **RdbPredicates**. Adds the OR condition to the **RdbPredicates**.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa") predicates.equalTo("NAME", "Lisa")
...@@ -334,22 +468,22 @@ predicates.equalTo("NAME", "Lisa") ...@@ -334,22 +468,22 @@ predicates.equalTo("NAME", "Lisa")
.equalTo("NAME", "Rose") .equalTo("NAME", "Rose")
``` ```
### and ### and
and(): RdbPredicates and(): RdbPredicates
Adds the AND condition to the **RdbPredicates**. Adds the AND condition to the **RdbPredicates**.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa") predicates.equalTo("NAME", "Lisa")
...@@ -357,7 +491,6 @@ predicates.equalTo("NAME", "Lisa") ...@@ -357,7 +491,6 @@ predicates.equalTo("NAME", "Lisa")
.equalTo("SALARY", 200.5) .equalTo("SALARY", 200.5)
``` ```
### contains ### contains
contains(field: string, value: string): RdbPredicates contains(field: string, value: string): RdbPredicates
...@@ -367,193 +500,200 @@ Sets an **RdbPredicates** to match a string containing the specified value. ...@@ -367,193 +500,200 @@ Sets an **RdbPredicates** to match a string containing the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.| | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.contains("NAME", "os") predicates.contains("NAME", "os")
``` ```
### beginsWith ### beginsWith
beginsWith(field: string, value: string): RdbPredicates beginsWith(field: string, value: string): RdbPredicates
Sets an **RdbPredicates** to match a string that starts with the specified value. Sets an **RdbPredicates** to match a string that starts with the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.| | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.beginsWith("NAME", "os") predicates.beginsWith("NAME", "os")
``` ```
### endsWith ### endsWith
endsWith(field: string, value: string): RdbPredicates endsWith(field: string, value: string): RdbPredicates
Sets an **RdbPredicates** to match a string that ends with the specified value. Sets an **RdbPredicates** to match a string that ends with the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.| | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.endsWith("NAME", "se") predicates.endsWith("NAME", "se")
``` ```
### isNull ### isNull
isNull(field: string): RdbPredicates isNull(field: string): RdbPredicates
Sets an **RdbPredicates** to match the field whose value is null. Sets an **RdbPredicates** to match the field whose value is null.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
- Example **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.isNull("NAME") predicates.isNull("NAME")
``` ```
### isNotNull ### isNotNull
isNotNull(field: string): RdbPredicates isNotNull(field: string): RdbPredicates
Sets an **RdbPredicates** to match the field whose value is not null. Sets an **RdbPredicates** to match the field whose value is not null.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.isNotNull("NAME") predicates.isNotNull("NAME")
``` ```
### like ### like
like(field: string, value: string): RdbPredicates like(field: string, value: string): RdbPredicates
Sets an **RdbPredicates** to match a string that is similar to the specified value. Sets an **RdbPredicates** to match a string that is similar to the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.| | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.like("NAME", "%os%") predicates.like("NAME", "%os%")
``` ```
### glob ### glob
glob(field: string, value: string): RdbPredicates glob(field: string, value: string): RdbPredicates
Sets an **RdbPredicates** to match the specified string. Sets an **RdbPredicates** to match the specified string.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.| | value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.glob("NAME", "?h*g") predicates.glob("NAME", "?h*g")
``` ```
### between ### between
between(field: string, low: ValueType, high: ValueType): RdbPredicates between(field: string, low: ValueType, high: ValueType): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **ValueType** and value within the specified range. Sets an **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
...@@ -561,27 +701,28 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -561,27 +701,28 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.| | high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.between("AGE", 10, 50) predicates.between("AGE", 10, 50)
``` ```
### notBetween ### notBetween
notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range. Sets an **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
...@@ -589,17 +730,18 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -589,17 +730,18 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.| | high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notBetween("AGE", 10, 50) predicates.notBetween("AGE", 10, 50)
``` ```
### greaterThan ### greaterThan
greaterThan(field: string, value: ValueType): RdbPredicates greaterThan(field: string, value: ValueType): RdbPredicates
...@@ -609,259 +751,265 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -609,259 +751,265 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.greaterThan("AGE", 18) predicates.greaterThan("AGE", 18)
``` ```
### lessThan ### lessThan
lessThan(field: string, value: ValueType): RdbPredicates lessThan(field: string, value: ValueType): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value. Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.lessThan("AGE", 20) predicates.lessThan("AGE", 20)
``` ```
### greaterThanOrEqualTo ### greaterThanOrEqualTo
greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value. Sets an **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.greaterThanOrEqualTo("AGE", 18) predicates.greaterThanOrEqualTo("AGE", 18)
``` ```
### lessThanOrEqualTo ### lessThanOrEqualTo
lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value. Sets an **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.| | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.lessThanOrEqualTo("AGE", 20) predicates.lessThanOrEqualTo("AGE", 20)
``` ```
### orderByAsc ### orderByAsc
orderByAsc(field: string): RdbPredicates orderByAsc(field: string): RdbPredicates
Sets an **RdbPredicates** to match the column with values sorted in ascending order. Sets an **RdbPredicates** to match the column with values sorted in ascending order.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.orderByAsc("NAME") predicates.orderByAsc("NAME")
``` ```
### orderByDesc ### orderByDesc
orderByDesc(field: string): RdbPredicates orderByDesc(field: string): RdbPredicates
Sets an **RdbPredicates** to match the column with values sorted in descending order. Sets an **RdbPredicates** to match the column with values sorted in descending order.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.orderByDesc("AGE") predicates.orderByDesc("AGE")
``` ```
### distinct ### distinct
distinct(): RdbPredicates distinct(): RdbPredicates
Sets an **RdbPredicates** to filter out duplicate records. Sets an **RdbPredicates** to filter out duplicate records.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.|
**Example** **Example**
```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()
``` ```
### limitAs ### limitAs
limitAs(value: number): RdbPredicates limitAs(value: number): RdbPredicates
Sets an **RdbPredicates** to specify the maximum number of records. Sets an **RdbPredicates** to specify the maximum number of records.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | Yes| Maximum number of records.| | value | number | Yes| Maximum number of records.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").limitAs(3) predicates.equalTo("NAME", "Rose").limitAs(3)
``` ```
### offsetAs ### offsetAs
offsetAs(rowOffset: number): RdbPredicates offsetAs(rowOffset: number): RdbPredicates
Sets an **RdbPredicates** to specify the start position of the returned result. Sets an **RdbPredicates** to specify the start position of the returned result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| | rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").offsetAs(3) predicates.equalTo("NAME", "Rose").offsetAs(3)
``` ```
### groupBy ### groupBy
groupBy(fields: Array&lt;string&gt;): RdbPredicates groupBy(fields: Array&lt;string&gt;): RdbPredicates
Sets an **RdbPredicates** to group rows that have the same value into summary rows. Sets an **RdbPredicates** to group rows that have the same value into summary rows.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fields | Array&lt;string&gt; | Yes| Names of columns to group.| | fields | Array&lt;string&gt; | Yes| Names of columns to group.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.groupBy(["AGE", "NAME"]) predicates.groupBy(["AGE", "NAME"])
``` ```
### indexedBy ### indexedBy
indexedBy(field: string): RdbPredicates indexedBy(field: string): RdbPredicates
...@@ -871,86 +1019,87 @@ Sets an **RdbPredicates** object to specify the index column. ...@@ -871,86 +1019,87 @@ Sets an **RdbPredicates** object to specify the index column.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Name of the index column.| | field | string | Yes| Name of the index column.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.indexedBy("SALARY_INDEX") predicates.indexedBy("SALARY_INDEX")
``` ```
### in ### in
in(field: string, value: Array&lt;ValueType&gt;): RdbPredicates in(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value within the specified range. Sets an **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value within the specified range.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.| | value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.in("AGE", [18, 20]) predicates.in("AGE", [18, 20])
``` ```
### notIn ### notIn
notIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates notIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
Sets an **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value out of the specified range. Sets an **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value out of the specified range.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.| | value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notIn("NAME", ["Lisa", "Rose"]) predicates.notIn("NAME", ["Lisa", "Rose"])
``` ```
## RdbStore ## RdbStore
Provides methods to manage an RDB store. Provides methods to manage an RDB store.
Before using the following APIs, use [executeSql](#executesql) to initialize the database table structure and related data. For details, see [RDB Development](../../database/database-relational-guidelines.md). Before using the following APIs, use [executeSql](#executesql) to initialize the database table structure and related data. For details, see [RDB Development](../../database/database-relational-guidelines.md).
### insert ### insert
insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void
...@@ -960,6 +1109,7 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re ...@@ -960,6 +1109,7 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -967,6 +1117,7 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re ...@@ -967,6 +1117,7 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Example** **Example**
```js ```js
const valueBucket = { const valueBucket = {
"NAME": "Lisa", "NAME": "Lisa",
...@@ -983,7 +1134,6 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) { ...@@ -983,7 +1134,6 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) {
}) })
``` ```
### insert ### insert
insert(table: string, values: ValuesBucket):Promise&lt;number&gt; insert(table: string, values: ValuesBucket):Promise&lt;number&gt;
...@@ -993,17 +1143,20 @@ Inserts a row of data into a table. This API uses a promise to return the result ...@@ -993,17 +1143,20 @@ Inserts a row of data into a table. This API uses a promise to return the result
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Row of data to insert.| | values | [ValuesBucket](#valuesbucket) | Yes| Row of data to insert.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| | Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
**Example** **Example**
```js ```js
const valueBucket = { const valueBucket = {
"NAME": "Lisa", "NAME": "Lisa",
...@@ -1028,6 +1181,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur ...@@ -1028,6 +1181,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1035,6 +1189,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur ...@@ -1035,6 +1189,7 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
**Example** **Example**
```js ```js
const valueBucket1 = { const valueBucket1 = {
"NAME": "Lisa", "NAME": "Lisa",
...@@ -1074,17 +1229,20 @@ Batch inserts data into a table. This API uses a promise to return the result. ...@@ -1074,17 +1229,20 @@ Batch inserts data into a table. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes| An array of data to insert.| | values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes| An array of data to insert.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.| | Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
**Example** **Example**
```js ```js
const valueBucket1 = { const valueBucket1 = {
"NAME": "Lisa", "NAME": "Lisa",
...@@ -1123,13 +1281,15 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T ...@@ -1123,13 +1281,15 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.| | values | [ValuesBucket](#valuesbucket) | Yes| Data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.|
**Example** **Example**
```js ```js
const valueBucket = { const valueBucket = {
"NAME": "Rose", "NAME": "Rose",
...@@ -1148,7 +1308,6 @@ rdbStore.update(valueBucket, predicates, function (err, ret) { ...@@ -1148,7 +1308,6 @@ rdbStore.update(valueBucket, predicates, function (err, ret) {
}) })
``` ```
### update ### update
update(values: ValuesBucket, predicates: RdbPredicates):Promise&lt;number&gt; update(values: ValuesBucket, predicates: RdbPredicates):Promise&lt;number&gt;
...@@ -1158,17 +1317,20 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr ...@@ -1158,17 +1317,20 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The key-value pair is associated with the column name in the target table.| | values | [ValuesBucket](#valuesbucket) | Yes| Data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **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
const valueBucket = { const valueBucket = {
"NAME": "Rose", "NAME": "Rose",
...@@ -1191,9 +1353,12 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data ...@@ -1191,9 +1353,12 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data
Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1202,6 +1367,7 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj ...@@ -1202,6 +1367,7 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.|
**Example** **Example**
```js ```js
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
const valueBucket = { const valueBucket = {
...@@ -1220,15 +1386,19 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { ...@@ -1220,15 +1386,19 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) {
console.log("Updated row count: " + ret) console.log("Updated row count: " + ret)
}) })
``` ```
### update<sup>9+</sup> ### update<sup>9+</sup>
update(table: string, values: ValuesBucket, predicates: dataSharePredicates.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.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1236,11 +1406,13 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj ...@@ -1236,11 +1406,13 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** object.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** 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
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
const valueBucket = { const valueBucket = {
...@@ -1263,18 +1435,19 @@ promise.then(async (ret) => { ...@@ -1263,18 +1435,19 @@ promise.then(async (ret) => {
delete(predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void delete(predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa") predicates.equalTo("NAME", "Lisa")
...@@ -1287,7 +1460,6 @@ rdbStore.delete(predicates, function (err, rows) { ...@@ -1287,7 +1460,6 @@ rdbStore.delete(predicates, function (err, rows) {
}) })
``` ```
### delete ### delete
delete(predicates: RdbPredicates):Promise&lt;number&gt; delete(predicates: RdbPredicates):Promise&lt;number&gt;
...@@ -1297,16 +1469,19 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. ...@@ -1297,16 +1469,19 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.|
**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
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa") predicates.equalTo("NAME", "Lisa")
...@@ -1322,12 +1497,14 @@ promise.then((rows) => { ...@@ -1322,12 +1497,14 @@ promise.then((rows) => {
delete(table: string, predicates: dataSharePredicates.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.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1335,6 +1512,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1335,6 +1512,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.| | callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of rows updated.|
**Example** **Example**
```js ```js
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
let predicates = new dataSharePredicates.DataSharePredicates() let predicates = new dataSharePredicates.DataSharePredicates()
...@@ -1347,26 +1525,32 @@ rdbStore.delete("EMPLOYEE", predicates, function (err, rows) { ...@@ -1347,26 +1525,32 @@ rdbStore.delete("EMPLOYEE", predicates, function (err, rows) {
console.log("Deleted rows: " + rows) console.log("Deleted rows: " + rows)
}) })
``` ```
### delete<sup>9+</sup> ### delete<sup>9+</sup>
delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt; delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.|
**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
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
let predicates = new dataSharePredicates.DataSharePredicates() let predicates = new dataSharePredicates.DataSharePredicates()
...@@ -1388,6 +1572,7 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -1388,6 +1572,7 @@ Queries data from the RDB store based on specified conditions. This API uses an
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
...@@ -1395,6 +1580,7 @@ Queries data from the RDB store based on specified conditions. This API uses an ...@@ -1395,6 +1580,7 @@ Queries data from the RDB store based on specified conditions. This API uses an
| 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.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose") predicates.equalTo("NAME", "Rose")
...@@ -1408,7 +1594,6 @@ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (e ...@@ -1408,7 +1594,6 @@ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (e
}) })
``` ```
### query ### query
query(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt; query(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
...@@ -1418,17 +1603,20 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -1418,17 +1603,20 @@ Queries data from the RDB store based on specified conditions. This API uses a p
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.| | predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** 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.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose") predicates.equalTo("NAME", "Rose")
...@@ -1447,9 +1635,12 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column ...@@ -1447,9 +1635,12 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column
Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1479,9 +1670,12 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column ...@@ -1479,9 +1670,12 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column
Queries data from the RDB store based on specified conditions. This API uses a promise to return the result. Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.| | table | string | Yes| Name of the target table.|
...@@ -1495,6 +1689,7 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -1495,6 +1689,7 @@ Queries data from the RDB store based on specified conditions. This API uses a p
| Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example** **Example**
```js ```js
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
let predicates = new dataSharePredicates.DataSharePredicates() let predicates = new dataSharePredicates.DataSharePredicates()
...@@ -1529,9 +1724,10 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -1529,9 +1724,10 @@ Queries data from the RDB store of a remote device based on specified conditions
**Example** **Example**
```js ```js
let predicates = new rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.greaterThan("id", 0) predicates.greaterThan("id", 0)
rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, function(err, resultSet){ rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"],
function(err, resultSet){
if (err) { if (err) {
console.info("Failed to remoteQuery, err: " + err) console.info("Failed to remoteQuery, err: " + err)
return return
...@@ -1567,9 +1763,9 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -1567,9 +1763,9 @@ Queries data from the RDB store of a remote device based on specified conditions
**Example** **Example**
```js ```js
let predicates = new rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.greaterThan("id", 0) predicates.greaterThan("id", 0)
let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates) let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promise.then((resultSet) => { promise.then((resultSet) => {
console.info("ResultSet column names: " + resultSet.columnNames) console.info("ResultSet column names: " + resultSet.columnNames)
console.info("ResultSet column count: " + resultSet.columnCount) console.info("ResultSet column count: " + resultSet.columnCount)
...@@ -1587,6 +1783,7 @@ Queries data in the RDB store using the specified SQL statement. This API uses a ...@@ -1587,6 +1783,7 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sql | string | Yes| SQL statement to run.| | sql | string | Yes| SQL statement to run.|
...@@ -1594,6 +1791,7 @@ Queries data in the RDB store using the specified SQL statement. This API uses a ...@@ -1594,6 +1791,7 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
| 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.|
**Example** **Example**
```js ```js
rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) {
if (err) { if (err) {
...@@ -1605,7 +1803,6 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ...@@ -1605,7 +1803,6 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",
}) })
``` ```
### querySql<sup>8+</sup> ### querySql<sup>8+</sup>
querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;
...@@ -1615,17 +1812,20 @@ Queries data in the RDB store using the specified SQL statement. This API uses a ...@@ -1615,17 +1812,20 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sql | string | Yes| SQL statement to run.| | sql | string | Yes| SQL statement to run.|
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No| Arguments in the SQL statement.| | bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No| Arguments in the SQL statement.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| | Promise&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example** **Example**
```js ```js
let promise = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) let promise = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'])
promise.then((resultSet) => { promise.then((resultSet) => {
...@@ -1636,7 +1836,6 @@ promise.then((resultSet) => { ...@@ -1636,7 +1836,6 @@ promise.then((resultSet) => {
}) })
``` ```
### executeSql ### executeSql
executeSql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;void&gt;):void executeSql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;void&gt;):void
...@@ -1646,6 +1845,7 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -1646,6 +1845,7 @@ Executes an SQL statement that contains specified arguments but returns no value
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sql | string | Yes| SQL statement to run.| | sql | string | Yes| SQL statement to run.|
...@@ -1653,6 +1853,7 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -1653,6 +1853,7 @@ Executes an SQL statement that contains specified arguments but returns no value
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
**Example** **Example**
```js ```js
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) {
...@@ -1664,7 +1865,6 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { ...@@ -1664,7 +1865,6 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) {
}) })
``` ```
### executeSql ### executeSql
executeSql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;void&gt; executeSql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;void&gt;
...@@ -1674,17 +1874,20 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -1674,17 +1874,20 @@ Executes an SQL statement that contains specified arguments but returns no value
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sql | string | Yes| SQL statement to run.| | sql | string | Yes| SQL statement to run.|
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No| Arguments in the SQL statement.| | bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No| Arguments in the SQL statement.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = rdbStore.executeSql(SQL_CREATE_TABLE) let promise = rdbStore.executeSql(SQL_CREATE_TABLE)
...@@ -1704,19 +1907,24 @@ Starts the transaction before executing an SQL statement. ...@@ -1704,19 +1907,24 @@ Starts the transaction before executing an SQL statement.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Example** **Example**
```js ```js
rdbStore.beginTransaction() import featureAbility from '@ohos.ability.featureAbility'
const valueBucket = { var context = featureAbility.getContext()
const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) {
rdbStore.beginTransaction()
const valueBucket = {
"name": "lisi", "name": "lisi",
"age": 18, "age": 18,
"salary": 100.5, "salary": 100.5,
"blobType": new Uint8Array([1, 2, 3]), "blobType": new Uint8Array([1, 2, 3]),
} }
await rdbStore.insert("test", valueBucket) await rdbStore.insert("test", valueBucket)
rdbStore.commit() rdbStore.commit()
})
``` ```
### commit<sup>8+</sup> ### commit<sup>8+</sup>
commit():void commit():void
...@@ -1726,20 +1934,24 @@ Commits the executed SQL statements. ...@@ -1726,20 +1934,24 @@ Commits the executed SQL statements.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Example** **Example**
```js ```js
rdbStore.beginTransaction() import featureAbility from '@ohos.ability.featureAbility'
const valueBucket = { var context = featureAbility.getContext()
const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) {
rdbStore.beginTransaction()
const valueBucket = {
"name": "lisi", "name": "lisi",
"age": 18, "age": 18,
"salary": 100.5, "salary": 100.5,
"blobType": new Uint8Array([1, 2, 3]), "blobType": new Uint8Array([1, 2, 3]),
} }
await rdbStore.insert("test", valueBucket)
await rdbStore.insert("test", valueBucket) rdbStore.commit()
rdbStore.commit() })
``` ```
### rollBack<sup>8+</sup> ### rollBack<sup>8+</sup>
rollBack():void rollBack():void
...@@ -1749,8 +1961,13 @@ Rolls back the SQL statements that have been executed. ...@@ -1749,8 +1961,13 @@ Rolls back the SQL statements that have been executed.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Example** **Example**
```js ```js
try { import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
const STORE_CONFIG = { name: "RdbTest.db"}
data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) {
try {
rdbStore.beginTransaction() rdbStore.beginTransaction()
const valueBucket = { const valueBucket = {
"id": 1, "id": 1,
...@@ -1761,9 +1978,10 @@ try { ...@@ -1761,9 +1978,10 @@ try {
} }
await rdbStore.insert("test", valueBucket) await rdbStore.insert("test", valueBucket)
rdbStore.commit() rdbStore.commit()
} catch (e) { } catch (e) {
rdbStore.rollBack() rdbStore.rollBack()
} }
})
``` ```
### backup<sup>9+</sup> ### backup<sup>9+</sup>
...@@ -1775,12 +1993,14 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu ...@@ -1775,12 +1993,14 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| destName | string | Yes| Name of the RDB store backup file.| | destName | string | Yes| Name of the RDB store backup file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
**Example** **Example**
```js ```js
rdbStore.backup("dbBackup.db", function(err) { rdbStore.backup("dbBackup.db", function(err) {
if (err) { if (err) {
...@@ -1800,16 +2020,19 @@ Backs up an RDB store. This API uses a promise to return the result. ...@@ -1800,16 +2020,19 @@ Backs up an RDB store. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| destName | string | Yes| Name of the RDB store backup file.| | destName | string | Yes| Name of the RDB store backup file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
let promiseBackup = rdbStore.backup("dbBackup.db") let promiseBackup = rdbStore.backup("dbBackup.db")
promiseBackup.then(()=>{ promiseBackup.then(()=>{
...@@ -1828,12 +2051,14 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback ...@@ -1828,12 +2051,14 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| srcName | string | Yes| Name of the RDB store backup file.| | srcName | string | Yes| Name of the RDB store backup file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
**Example** **Example**
```js ```js
rdbStore.restore("dbBackup.db", function(err) { rdbStore.restore("dbBackup.db", function(err) {
if (err) { if (err) {
...@@ -1853,16 +2078,19 @@ Restores an RDB store from a backup file. This API uses a promise to return the ...@@ -1853,16 +2078,19 @@ Restores an RDB store from a backup file. This API uses a promise to return the
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| srcName | string | Yes| Name of the RDB store backup file.| | srcName | string | Yes| Name of the RDB store backup file.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
let promiseRestore = rdbStore.restore("dbBackup.db") let promiseRestore = rdbStore.restore("dbBackup.db")
promiseRestore.then(()=>{ promiseRestore.then(()=>{
...@@ -1883,12 +2111,14 @@ Sets distributed tables. This API uses an asynchronous callback to return the re ...@@ -1883,12 +2111,14 @@ Sets distributed tables. This API uses an asynchronous callback to return the re
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| tables | Array&lt;string&gt; | Yes| Names of the distributed tables to set.| | tables | Array&lt;string&gt; | Yes| Names of the distributed tables to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result.|
**Example** **Example**
```js ```js
rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { rdbStore.setDistributedTables(["EMPLOYEE"], function (err) {
if (err) { if (err) {
...@@ -1899,7 +2129,6 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { ...@@ -1899,7 +2129,6 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) {
}) })
``` ```
### setDistributedTables<sup>8+</sup> ### setDistributedTables<sup>8+</sup>
setDistributedTables(tables: Array&lt;string&gt;): Promise&lt;void&gt; setDistributedTables(tables: Array&lt;string&gt;): Promise&lt;void&gt;
...@@ -1911,22 +2140,25 @@ Sets distributed tables. This API uses a promise to return the result. ...@@ -1911,22 +2140,25 @@ Sets distributed tables. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| tables | Array&lt;string&gt; | Yes| Names of the distributed tables to set.| | tables | Array&lt;string&gt; | Yes| Names of the distributed tables to set.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
let promise = rdbStore.setDistributedTables(["EMPLOYEE"]) let promise = rdbStore.setDistributedTables(["EMPLOYEE"])
promise.then(() => { promise.then(() => {
console.info("Set distributed tables successfully.") console.info("Set distributed tables successfully.")
}).catch((err) => { }).catch((err) => {
console.info('Failed to set distributed tables, err: ' + err) console.info("Failed to set distributed tables, err: " + err)
}) })
``` ```
...@@ -1941,6 +2173,7 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1941,6 +2173,7 @@ Obtains the distributed table name for a remote device based on the local table
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | string | Yes| Remote device.| | device | string | Yes| Remote device.|
...@@ -1948,6 +2181,7 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1948,6 +2181,7 @@ Obtains the distributed table name for a remote device based on the local table
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Example** **Example**
```js ```js
rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) { rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) {
if (err) { if (err) {
...@@ -1958,7 +2192,6 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, ...@@ -1958,7 +2192,6 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err,
}) })
``` ```
### obtainDistributedTableName<sup>8+</sup> ### obtainDistributedTableName<sup>8+</sup>
obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt; obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
...@@ -1970,17 +2203,20 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1970,17 +2203,20 @@ Obtains the distributed table name for a remote device based on the local table
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | string | Yes| Remote device.| | device | string | Yes| Remote device.|
| table | string | Yes| Local table name.| | table | string | Yes| Local table name.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Example** **Example**
```js ```js
let promise = rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE") let promise = rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE")
promise.then((tableName) => { promise.then((tableName) => {
...@@ -2001,6 +2237,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -2001,6 +2237,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.| | mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
...@@ -2008,6 +2245,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -2008,6 +2245,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
| callback | AsyncCallback&lt;Array&lt;[string, number]&gt;&gt; | Yes| Callback invoked to send the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | | callback | AsyncCallback&lt;Array&lt;[string, number]&gt;&gt; | Yes| Callback invoked to send the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde']) predicates.inDevices(['12345678abcde'])
...@@ -2023,7 +2261,6 @@ rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, resul ...@@ -2023,7 +2261,6 @@ rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, resul
}) })
``` ```
### sync<sup>8+</sup> ### sync<sup>8+</sup>
sync(mode: SyncMode, predicates: RdbPredicates): Promise&lt;Array&lt;[string, number]&gt;&gt; sync(mode: SyncMode, predicates: RdbPredicates): Promise&lt;Array&lt;[string, number]&gt;&gt;
...@@ -2035,6 +2272,7 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -2035,6 +2272,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.| | mode | [SyncMode](#syncmode8) | Yes| Data synchronization mode. The value can be **push** or **pull**.|
...@@ -2047,6 +2285,7 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -2047,6 +2285,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
| Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to return the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | | Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to return the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde']) predicates.inDevices(['12345678abcde'])
...@@ -2080,6 +2319,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes ...@@ -2080,6 +2319,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes
| observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Observer that listens for the data changes in the RDB store.| | observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Observer that listens for the data changes in the RDB store.|
**Example** **Example**
```js ```js
function storeObserver(devices) { function storeObserver(devices) {
for (let i = 0; i < devices.length; i++) { for (let i = 0; i < devices.length; i++) {
...@@ -2112,6 +2352,7 @@ Unregisters the observer of the specified type from the RDB store. This API uses ...@@ -2112,6 +2352,7 @@ Unregisters the observer of the specified type from the RDB store. This API uses
| observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Data change observer registered.| | observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Data change observer registered.|
**Example** **Example**
```js ```js
function storeObserver(devices) { function storeObserver(devices) {
for (let i = 0; i < devices.length; i++) { for (let i = 0; i < devices.length; i++) {
...@@ -2127,14 +2368,14 @@ try { ...@@ -2127,14 +2368,14 @@ try {
## StoreConfig ## StoreConfig
Manages the configuration of an RDB store. Defines the RDB store configuration.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Database file name.| | name | string | Yes| Database file name.|
| encrypt<sup>9+</sup> | boolean | No| Whether to encrypt the RDB store.<br>The value **true** means to encrypt the RDB store, and the value **false** means the opposite.|
## ValueType ## ValueType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册