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

!4802 【RDB】weekly0531接口参考文档增加权限描述

Merge pull request !4802 from Cap_W/weekly_20220531
...@@ -141,6 +141,8 @@ ...@@ -141,6 +141,8 @@
### 设置分布式列表 ### 设置分布式列表
>**注意:** 在使用RdbStore的setDistributedTables、obtainDistributedTableName、sync、on、off接口时,需要请求相应的权限:ohos.permission.DISTRIBUTED_DATASYNC。
**设置分布式列表** **设置分布式列表**
**表8** 设置分布式列表 **表8** 设置分布式列表
...@@ -242,12 +244,25 @@ ...@@ -242,12 +244,25 @@
``` ```
4. 设置分布式同步表。 4. 设置分布式同步表。
1. 数据库调用接口设置分布式同步列表。
2. 判断是否设置成功。 1.权限配置文件中增加以下配置:
```js
"requestPermissions":
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
```
2. 获取应用权限。
3. 数据库调用接口设置分布式同步列表。
4. 判断是否设置成功。
示例代码如下: 示例代码如下:
```js ```js
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
let promise = rdbStore.setDistributedTables(["test"]) let promise = rdbStore.setDistributedTables(["test"])
promise.then(() => { promise.then(() => {
console.info("setDistributedTables success.") console.info("setDistributedTables success.")
...@@ -256,10 +271,10 @@ ...@@ -256,10 +271,10 @@
}) })
``` ```
5. 分布式数据同步。 5. 分布式数据同步。
1. 构造用于同步分布式表的谓词对象,指定组网内的远程设备。 1. 构造用于同步分布式表的谓词对象,指定组网内的远程设备。
2. 调用同步数据的接口 。 2. 调用同步数据的接口 。
3. 判断是否数据同步成功。 3. 判断数据同步是否成功。
示例代码如下: 示例代码如下:
......
...@@ -1734,6 +1734,8 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi ...@@ -1734,6 +1734,8 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi
设置分布式列表,结果以callback形式返回。 设置分布式列表,结果以callback形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1760,6 +1762,8 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { ...@@ -1760,6 +1762,8 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) {
设置分布式列表,结果以Promise形式返回。 设置分布式列表,结果以Promise形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1788,6 +1792,8 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac ...@@ -1788,6 +1792,8 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac
根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 结果以callback形式返回。 根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名, 结果以callback形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1815,6 +1821,8 @@ rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableNa ...@@ -1815,6 +1821,8 @@ rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableNa
根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,结果以Promise形式返回。 根据本地表名获取指定远程设备的分布式表名。在查询远程设备数据库时,需要使用分布式表名,结果以Promise形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1844,6 +1852,8 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array ...@@ -1844,6 +1852,8 @@ sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array
在设备之间同步数据, 结果以callback形式返回。 在设备之间同步数据, 结果以callback形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1876,6 +1886,8 @@ rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { ...@@ -1876,6 +1886,8 @@ rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
在设备之间同步数据,结果以Promise形式返回。 在设备之间同步数据,结果以Promise形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1911,6 +1923,8 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri ...@@ -1911,6 +1923,8 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
注册数据库的观察者。当分布式数据库中的数据发生更改时,将调用回调。 注册数据库的观察者。当分布式数据库中的数据发生更改时,将调用回调。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -1941,6 +1955,8 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri ...@@ -1941,6 +1955,8 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
从数据库中删除指定类型的指定观察者, 结果以callback形式返回。 从数据库中删除指定类型的指定观察者, 结果以callback形式返回。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。
**参数:** **参数:**
...@@ -2015,6 +2031,8 @@ try { ...@@ -2015,6 +2031,8 @@ try {
描述订阅类型。 描述订阅类型。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.RelationalStore.Core。
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册