Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a3f845fe
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a3f845fe
编写于
6月 26, 2023
作者:
R
renjiecui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify docs
Signed-off-by:
N
renjiecui
<
cuirenjie@huawei.com
>
上级
27380221
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
79 addition
and
132 deletion
+79
-132
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
...cation-dev/reference/apis/js-apis-data-relationalStore.md
+79
-132
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
浏览文件 @
a3f845fe
...
@@ -343,6 +343,9 @@ class EntryAbility extends UIAbility {
...
@@ -343,6 +343,9 @@ class EntryAbility extends UIAbility {
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| ------------------------------- | --- | -------------- |
| ------------------------------- | --- | -------------- |
| ASSET_NORMAL | - | 表示资产状态正常。 |
| ASSET_NORMAL | - | 表示资产状态正常。 |
| ASSET_INSERT | - | 表示资产需要插入到云端。 |
| ASSET_UPLOAD | - | 表示资产需要更新到云端。 |
| ASSET_DELETE | - | 表示资产需要在云端删除。 |
| ASSET_ABNORMAL | - | 表示资产状态异常。 |
| ASSET_ABNORMAL | - | 表示资产状态异常。 |
| ASSET_DOWNLOADING | - | 表示资产正在下载到本地设备。 |
| ASSET_DOWNLOADING | - | 表示资产正在下载到本地设备。 |
...
@@ -368,7 +371,7 @@ class EntryAbility extends UIAbility {
...
@@ -368,7 +371,7 @@ class EntryAbility extends UIAbility {
| 类型 | 说明 |
| 类型 | 说明 |
| ------- | -------------------- |
| ------- | -------------------- |
|
[
Asset
](
#asset10
)[]
| 表示
[
Asset
](
#asset10
)
类型的数组。 |
|
[
Asset
](
#asset10
)[]
| 表示
Asset
类型的数组。 |
## ValueType
## ValueType
...
@@ -384,7 +387,7 @@ class EntryAbility extends UIAbility {
...
@@ -384,7 +387,7 @@ class EntryAbility extends UIAbility {
| boolean | 表示值类型为布尔值。 |
| boolean | 表示值类型为布尔值。 |
| Uint8Array | 表示值类型为Uint8类型的数组。 |
| Uint8Array | 表示值类型为Uint8类型的数组。 |
| Asset
<sup>
10+
</sup>
| 表示值类型为附件
[
Asset
](
#asset10
)
。 |
| Asset
<sup>
10+
</sup>
| 表示值类型为附件
[
Asset
](
#asset10
)
。 |
| Ass
te
s
<sup>
10+
</sup>
| 表示值类型为附件数组
[
Assets
](
#assets10
)
。 |
| Ass
et
s
<sup>
10+
</sup>
| 表示值类型为附件数组
[
Assets
](
#assets10
)
。 |
## ValuesBucket
## ValuesBucket
...
@@ -400,8 +403,6 @@ class EntryAbility extends UIAbility {
...
@@ -400,8 +403,6 @@ class EntryAbility extends UIAbility {
指数据库同步模式。
指数据库同步模式。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| -------------- | ---- | ---------------------------------- |
| -------------- | ---- | ---------------------------------- |
| SYNC_MODE_PUSH | 0 | 表示数据从本地设备推送到远程设备。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| SYNC_MODE_PUSH | 0 | 表示数据从本地设备推送到远程设备。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
...
@@ -428,6 +429,8 @@ class EntryAbility extends UIAbility {
...
@@ -428,6 +429,8 @@ class EntryAbility extends UIAbility {
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| -------------------------- | --- | -------------------------- |
| -------------------------- | --- | -------------------------- |
| DATA_CHANGE | - | 表示是数据发生变更。请使用枚举名称而非枚举值。 |
| DATA_CHANGE | - | 表示是数据发生变更。请使用枚举名称而非枚举值。 |
...
@@ -442,7 +445,7 @@ class EntryAbility extends UIAbility {
...
@@ -442,7 +445,7 @@ class EntryAbility extends UIAbility {
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------- |
| -------- | ---------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------- |
| table | string | 是 | 表示发生变化的表的名称。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| table | string | 是 | 表示发生变化的表的名称。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| type |
[
ChangeType
](
#changetype
)
| 是 | 表示发生变化的数据的类型,数据或者资产附件发生变化。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| type |
[
ChangeType
](
#changetype
10
)
| 是 | 表示发生变化的数据的类型,数据或者资产附件发生变化。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| inserted | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录插入数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示插入数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| inserted | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录插入数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示插入数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| updated | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录更新数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示更新数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| updated | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录更新数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示更新数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| deleted | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录删除数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示删除数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
| deleted | Array
\<
string
\>
\|
Array
\<
number
\>
| 是 | 记录删除数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表示删除数据的行号。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core |
...
@@ -451,9 +454,11 @@ class EntryAbility extends UIAbility {
...
@@ -451,9 +454,11 @@ class EntryAbility extends UIAbility {
描述表的分布式类型的枚举。
描述表的分布式类型的枚举。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
| DISTRIBUTED_DEVICE | 0 | 表示表在不同设备之间分布式。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore. |
| DISTRIBUTED_DEVICE | 0 | 表示表在不同设备之间分布式。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.
Core
|
| DISTRIBUTED_CLOUD | - | 表示表在设备和云端之间分布式。请使用枚举名称而非枚举值。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Client |
| DISTRIBUTED_CLOUD | - | 表示表在设备和云端之间分布式。请使用枚举名称而非枚举值。
<br>
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Client |
## DistributedConfig<sup>10+</sup>
## DistributedConfig<sup>10+</sup>
...
@@ -463,8 +468,8 @@ class EntryAbility extends UIAbility {
...
@@ -463,8 +468,8 @@ class EntryAbility extends UIAbility {
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------- | ---
|
------------------------------------------------------ |
| -------- | ------- | ---
- | ------
------------------------------------------------------ |
| autoSync | boolean | 是 | 该值为true时,表示该表支持自动同步和手动同步;该值为false时,表示该表只支持手动同步,不支持自动同步。 |
| autoSync | boolean | 是 | 该值为true时,表示该表支持自动同步和手动同步;该值为false时,表示该表只支持手动同步,不支持自动同步。
<br>
默认值是false。
|
## ConflictResolution<sup>10+</sup>
## ConflictResolution<sup>10+</sup>
...
@@ -2960,11 +2965,11 @@ store.setDistributedTables(["EMPLOYEE"], function (err) {
...
@@ -2960,11 +2965,11 @@ store.setDistributedTables(["EMPLOYEE"], function (err) {
})
})
```
```
### setDistributedTables
### setDistributedTables
<sup>10+</sup>
setDistributedTables(tables: Array
<
string
>
): Promise
<
void
>
setDistributedTables(tables: Array
<
string
>
, type: DistributedType, callback: AsyncCallback
<
void
>
): void
设置分布式列表,使用
Promise
异步回调。
设置分布式列表,使用
callback
异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -2973,38 +2978,36 @@ store.setDistributedTables(["EMPLOYEE"], function (err) {
...
@@ -2973,38 +2978,36 @@ store.setDistributedTables(["EMPLOYEE"], function (err) {
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------- | ---- | ------------------------ |
| -------- | ------------------------------------ | ---- | ---------------------- |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名。 |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名 |
| type |
[
DistributedType
](
distributedtype10
)
| 是 | 表的分布式类型。 |
**返回值**
:
| callback | AsyncCallback
<
void
>
| 是 | 指定callback回调函数。 |
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
关系型数据库错误码
](
../errorcodes/errorcode-data-rdb.md
)
。
以下错误码的详细介绍请参见
[
关系型数据库错误码
](
../errorcodes/errorcode-data-rdb.md
)
。
|
**错误码ID**
|
**错误信息**
|
|
**错误码ID**
|
**错误信息**
|
| ------------ | ------------
----------------
|
| ------------ | ------------ |
| 14800000 | Inner error. |
| 14800000 | Inner error. |
**示例:**
**示例:**
```
js
```
js
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
]);
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
DistributedType
.
DISTRIBUTED_CLOUD
,
function
(
err
)
{
promise
.
then
(()
=>
{
if
(
err
)
{
console
.
info
(
`SetDistributedTables successfully.`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
}
console
.
info
(
`SetDistributedTables successfully.`
);
})
})
```
```
### setDistributedTables<sup>10+</sup>
setDistributedTables(tables: Array
<
string
>
, type: DistributedType, callback: AsyncCallback
<
void
>
): void
### setDistributedTables
设置分布式列表,使用callback异步回调。
setDistributedTables(
*tables*
: Array
<
string>, type?: DistributedType, config?: DistributedConfig): Promise
<
void>
设置分布式列表,使用Promise异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3013,32 +3016,42 @@ setDistributedTables(tables: Array<string>, type: DistributedType, callbac
...
@@ -3013,32 +3016,42 @@ setDistributedTables(tables: Array<string>, type: DistributedType, callbac
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------
-- | ----------------------------------- | --- |
--------------- |
| ------
| ----------------------------------------- | ---- | -------------------------------------
--------------- |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名。 |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名。 |
| type |
[
DistributedType
](
#distributedtype
)
| 是 | 表的分布式类型。 |
| type | number | 否 | 表的分布式类型。
<br>
API version 10新增可选参数。 |
| callback | AsyncCallback
<
void
>
| 是 | 指定callback回调函数。 |
| config |
[
DistributedConfig
](
#distributedconfig10
)
| 否 | 表的分布式配置信息。
<br/>
API version 10新增可选参数 |
**返回值**
:
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
关系型数据库错误码
](
../errorcodes/errorcode-data-rdb.md
)
。
以下错误码的详细介绍请参见
[
关系型数据库错误码
](
../errorcodes/errorcode-data-rdb.md
)
。
|
**错误码ID**
|
**错误信息**
|
| ------------ | ---------------------------- |
| 14800000 | Inner error. |
**示例:**
**示例:**
```
js
```
js
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
DistributedType
.
DISTRIBUTED_CLOUD
,
function
(
err
)
{
let
config
=
new
DistributedConfig
();
if
(
err
)
{
config
.
autoSync
=
true
;
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
DistributedType
.
DISTRIBUTED_CLOUD
,
config
);
return
;
promise
.
then
(()
=>
{
}
console
.
info
(
`SetDistributedTables successfully.`
);
console
.
info
(
`SetDistributedTables successfully.`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
})
})
```
```
### setDistributedTables<sup>10+</sup>
### setDistributedTables<sup>10+</sup>
setDistributedTables(tables: Array
<
string
>
, type?: number, config?: DistributedConfig): Promise
<
void
>
setDistributedTables(tables: Array
<
string
>
, type: number, config: DistributedConfig, callback: AsyncCallback
<
void
>
): void
设置分布式列表,使用
Promise
异步回调。
设置分布式列表,使用
callback
异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3047,27 +3060,23 @@ store.setDistributedTables(["EMPLOYEE"], DistributedType.DISTRIBUTED_CLOUD, func
...
@@ -3047,27 +3060,23 @@ store.setDistributedTables(["EMPLOYEE"], DistributedType.DISTRIBUTED_CLOUD, func
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------
| --------------------------------------- | --- |
------------ |
| ------
-- | ----------------------------------- | --- | ---
------------ |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名。 |
| tables | Array
<
string
>
| 是 | 要设置的分布式列表表名。 |
| type |
[
DistributedType
](
#distributedtype
)
| 否 | 表的分布式类型。 |
| type | number | 是 | 表的分布式类型。 |
| config |
[
DistributedConfig
](
#distributedconfig
)
| 否 | 表的分布式配置信息。 |
| config |
[
DistributedConfig
](
#distributedconfig10
)
| 是 | 表的分布式配置信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 指定callback回调函数。 |
**返回值**
:
| 类型 | 说明 |
| ------------------- | ---------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
**示例:**
```
js
```
js
let
config
=
new
DistributedConfig
();
let
config
=
new
DistributedConfig
();
config
.
autoSync
=
true
;
config
.
autoSync
=
true
;
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
DistributedType
.
DISTRIBUTED_CLOUD
,
config
);
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
DistributedType
.
DISTRIBUTED_CLOUD
,
config
,
function
(
err
)
{
promise
.
then
(()
=>
{
if
(
err
)
{
console
.
info
(
`SetDistributedTables successfully.`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
console
.
error
(
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
}
console
.
info
(
`SetDistributedTables successfully.`
);
})
})
```
```
...
@@ -3311,9 +3320,9 @@ promise.then((result) =>{
...
@@ -3311,9 +3320,9 @@ promise.then((result) =>{
### on('dataChange')
### on('dataChange')
on(event: 'dataChange', type: SubscribeType, observer: Callback
<
Array
<
string
>>
): void
on(event: 'dataChange', type: SubscribeType, observer: Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
ChangeInfo
>>
): void
注册数据库的
观察者
。当分布式数据库中的数据发生更改时,将调用回调。
注册数据库的
数据变更的事件监听
。当分布式数据库中的数据发生更改时,将调用回调。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -3323,7 +3332,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
...
@@ -3323,7 +3332,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
| -------- | ----------------------------------- | ---- | ------------------------------------------- |
| -------- | ----------------------------------- | ---- | ------------------------------------------- |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| observer | Callback
<
Array
<
string
>>
| 是 | 指分布式数据库中数据更改事件的观察者。Array
<
string>为数据库中的数据发生改变的对端设备ID
。 |
| observer | Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
ChangeInfo
>>
<sup>
10+
</sup>
| 是 | 回调函数。
<br>
当type为SUBSCRIBE_TYPE_REMOTE,observer类型需为Callback
<
Array
<
string
>>
,其中Array
<
string
>
为数据库中的数据发生改变的对端设备ID。
<br>
当type为SUBSCRIBE_TYPE_CLOUD,observer类型需为Callback
<
Array
<
string
>>
,其中Array
<
string
>
为数据库中的数据发生改变的云端账号ID。
<br>
当type为SUBSCRIBE_TYPE_CLOUD_DETAILS,observer类型需为Callback
<
Array
<
ChangeInfo
>>
,其中Array
<
ChangeInfo
>
为数据库端云同步过程的详情
。 |
**示例:**
**示例:**
...
@@ -3340,42 +3349,11 @@ try {
...
@@ -3340,42 +3349,11 @@ try {
}
}
```
```
### on('dataChange')<sup>10+</sup>
on(event: 'dataChange', type: SubscribeType, observer: Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
[ChangeInfo](#changeinfo)
>>
): void
注册数据库的观察者。当分布式数据库中的数据发生更改时,将调用回调。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------------------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| observer | Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
[ChangeInfo](#changeinfo)
>>
| 是 | 指分布式数据库中数据更改事件的观察者。Array
<
string>为数据库中的数据发生改变的对端设备ID。 Array
<
[ChangeInfo](#changeinfo)
>
为数据库中的数据发生改变的信息,只有订阅类型为SUBSCRIBE_TYPE_CLOUD_DETAILS时才可以使用。 |
**示例:**
```
js
function
storeObserver
(
devices
)
{
for
(
let
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
console
.
info
(
`device=
${
devices
[
i
]}
data changed`
);
}
}
try
{
store
.
on
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
storeObserver
);
}
catch
(
err
)
{
console
.
error
(
`Register observer failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
}
```
### off('dataChange')
### off('dataChange')
off(event:'dataChange', type: SubscribeType, observer
: Callback
<
Array
<
string
>>
): void
off(event:'dataChange', type: SubscribeType, observer
?: Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
ChangeInfo
>>
): void
从数据库中删除指定类型的指定观察者, 使用callback异步回调
。
取消数据变更的事件监听
。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -3385,7 +3363,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
...
@@ -3385,7 +3363,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
| -------- | ---------------------------------- | ---- | ------------------------------------------ |
| -------- | ---------------------------------- | ---- | ------------------------------------------ |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| observer | Callback
<
Array
<
string
>>
|
是 | 指已注册的数据更改观察者。Array
<
string>为数据库中的数据发生改变的对端设备ID
。 |
| observer | Callback
<
Array
<
string
>>
|
否 | 回调函数。
<br/>
当type为SUBSCRIBE_TYPE_REMOTE,observer类型需为Callback
<
Array
<
string
>>
,其中Array
<
string
>
为数据库中的数据发生改变的对端设备ID。
<br/>
当type为SUBSCRIBE_TYPE_CLOUD,observer类型需为Callback
<
Array
<
string
>>
,其中Array
<
string
>
为数据库中的数据发生改变的云端账号ID。
<br/>
当type为SUBSCRIBE_TYPE_CLOUD_DETAILS,observer类型需为Callback
<
Array
<
ChangeInfo
>>
,其中Array
<
ChangeInfo
>
为数据库端云同步过程的详情。
<br>
当observer没有传入时,表示取消当前type类型下所有数据变更的事件监听
。 |
**示例:**
**示例:**
...
@@ -3402,37 +3380,6 @@ try {
...
@@ -3402,37 +3380,6 @@ try {
}
}
```
```
### off('dataChange')<sup>10+</sup>
off(event: 'dataChange', type: SubscribeType, observer: Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
[ChangeInfo](#changeinfo)
>>
): void
从数据库中删除指定类型的指定观察者, 使用callback异步回调。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------------------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| event | string | 是 | 取值为'dataChange',表示数据更改。 |
| type |
[
SubscribeType
](
#subscribetype
)
| 是 | 订阅类型。 |
| observer | Callback
<
Array
<
string
>>
\|
Callback
<
Array
<
[ChangeInfo](#changeinfo)
>>
| 否 | 指分布式数据库中数据更改事件的观察者。Array
<
string>为数据库中的数据发生改变的对端设备ID。 Array
<
[ChangeInfo](#changeinfo)
>
为数据库中的数据发生改变的信息,只有订阅类型为SUBSCRIBE_TYPE_CLOUD_DETAILS时才可以使用。 |
**示例:**
```
js
function
storeObserver
(
devices
)
{
for
(
let
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
console
.
info
(
`device=
${
devices
[
i
]}
data changed`
);
}
}
try
{
store
.
off
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
storeObserver
);
}
catch
(
err
)
{
console
.
error
(
`Unregister observer failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
}
```
## ResultSet
## ResultSet
提供通过查询数据库生成的数据库结果集的访问方法。结果集是指用户调用关系型数据库查询接口之后返回的结果集合,提供了多种灵活的数据访问方式,以便用户获取各项数据。
提供通过查询数据库生成的数据库结果集的访问方法。结果集是指用户调用关系型数据库查询接口之后返回的结果集合,提供了多种灵活的数据访问方式,以便用户获取各项数据。
...
@@ -3906,7 +3853,7 @@ const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
...
@@ -3906,7 +3853,7 @@ const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
getAsset(columnIndex: number): Asset
getAsset(columnIndex: number): Asset
以
[
Asset
](
#asset
)
形式获取当前行中指定列的值。
以
[
Asset
](
#asset
10
)
形式获取当前行中指定列的值。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -3920,7 +3867,7 @@ getAsset(columnIndex: number): Asset
...
@@ -3920,7 +3867,7 @@ getAsset(columnIndex: number): Asset
| 类型 | 说明 |
| 类型 | 说明 |
| --------------- | -------------------------- |
| --------------- | -------------------------- |
|
[
Asset
](
#asset
)
| 以
[
Asset
](
#asset
)
形式返回指定列的值。 |
|
[
Asset
](
#asset
10
)
| 以
[
Asset
](
#asset10
)
形式返回指定列的值。 |
**错误码:**
**错误码:**
...
@@ -3928,7 +3875,7 @@ getAsset(columnIndex: number): Asset
...
@@ -3928,7 +3875,7 @@ getAsset(columnIndex: number): Asset
|
**错误码ID**
|
**错误信息**
|
|
**错误码ID**
|
**错误信息**
|
| --------- | ------------------------------------------------------------ |
| --------- | ------------------------------------------------------------ |
| 14800013 |
T
he column value is null or the column type is incompatible. |
| 14800013 |
t
he column value is null or the column type is incompatible. |
**示例:**
**示例:**
...
@@ -3938,9 +3885,9 @@ const doc = resultSet.getAsset(resultSet.getColumnIndex("DOC"));
...
@@ -3938,9 +3885,9 @@ const doc = resultSet.getAsset(resultSet.getColumnIndex("DOC"));
### getAssets<sup>10+</sup>
### getAssets<sup>10+</sup>
getAsset(columnIndex: number): Assets
getAsset
s
(columnIndex: number): Assets
以
[
Assets
](
#assets
)
形式获取当前行中指定列的值。
以
[
Assets
](
#assets
10
)
形式获取当前行中指定列的值。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -3954,7 +3901,7 @@ getAsset(columnIndex: number): Assets
...
@@ -3954,7 +3901,7 @@ getAsset(columnIndex: number): Assets
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------- | ---------------------------- |
| ---------------- | ---------------------------- |
|
[
Assets
](
#assets
)
| 以
[
Assets
](
#assets
)
形式返回指定列的值。 |
|
[
Assets
](
#assets
10
)
| 以Assets
形式返回指定列的值。 |
**错误码:**
**错误码:**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录