Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
325b80a4
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看板
提交
325b80a4
编写于
7月 10, 2023
作者:
R
renjiecui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify docs
Signed-off-by:
N
renjiecui
<
cuirenjie@huawei.com
>
上级
7594ceaa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
56 deletion
+66
-56
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
...cation-dev/reference/apis/js-apis-data-relationalStore.md
+66
-56
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
浏览文件 @
325b80a4
...
@@ -403,7 +403,7 @@ class EntryAbility extends UIAbility {
...
@@ -403,7 +403,7 @@ class EntryAbility extends UIAbility {
## PRIKeyType<sup>10+</sup>
## PRIKeyType<sup>10+</sup>
数据库表某一行的主键
。
用于表示数据库表某一行主键的数据类型
。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -413,7 +413,7 @@ class EntryAbility extends UIAbility {
...
@@ -413,7 +413,7 @@ class EntryAbility extends UIAbility {
## UTCTime<sup>10+</sup>
## UTCTime<sup>10+</sup>
UTC类型的时间
。
用于表示UTC类型时间的数据类型
。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -423,7 +423,7 @@ UTC类型的时间。
...
@@ -423,7 +423,7 @@ UTC类型的时间。
## ModifyTime<sup>10+</sup>
## ModifyTime<sup>10+</sup>
用于存储
主键和修改时间的Map
。
用于存储
数据库表的主键和修改时间的数据类型
。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
...
@@ -560,15 +560,15 @@ UTC类型的时间。
...
@@ -560,15 +560,15 @@ UTC类型的时间。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明
|
| --------------------- | ---- | ------------------------------------------------------ |
| --------------------- | ---- | ------------------------------------------------------
------
|
| SUCCESS | - | 表示端云同步过程成功。 |
| SUCCESS | - | 表示端云同步过程成功。
|
| UNKNOWN_ERROR | - | 表示端云同步过程遇到未知错误。 |
| UNKNOWN_ERROR | - | 表示端云同步过程遇到未知错误。
|
| NETWORK_ERROR | - | 表示端云同步过程遇到网络错误。 |
| NETWORK_ERROR | - | 表示端云同步过程遇到网络错误。
|
| CLOUD_DISABLED | - | 表示云端不可用。 |
| CLOUD_DISABLED | - | 表示云端不可用。
|
| LOCKED_BY_OTHERS | - | 表示有其他设备正在端云同步
。
|
| LOCKED_BY_OTHERS | - | 表示有其他设备正在端云同步
,本设备无法进行端云同步。
<br>
请确保无其他设备占用云端资源后,再使用本设备进行端云同步任务。
|
| RECORD_LIMIT_EXCEEDED | - | 表示本次端云同步需要同步的条目或大小超出最大
限制
。 |
| RECORD_LIMIT_EXCEEDED | - | 表示本次端云同步需要同步的条目或大小超出最大
值。由云端配置最大值
。 |
| NO_SPACE_FOR_ASSET | - | 表示云空间剩余空间小于待同步的资产大小。 |
| NO_SPACE_FOR_ASSET | - | 表示云空间剩余空间小于待同步的资产大小。
|
## ProgressDetails<sup>10+</sup>
## ProgressDetails<sup>10+</sup>
...
@@ -2761,25 +2761,20 @@ promise.then(() => {
...
@@ -2761,25 +2761,20 @@ promise.then(() => {
### getModifyTime<sup>10+</sup>
### getModifyTime<sup>10+</sup>
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]
): Promise
<
ModifyTime
>
;
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]
, callback: AsyncCallback
<
ModifyTime
>
): void
获取数据库表中数据的最后修改时间,使用
Promise
异步回调。
获取数据库表中数据的最后修改时间,使用
callback
异步回调。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ----------------------------- | ---- | ---------------------------- |
| ----------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| table | string | 是 | 指定要查询的数据库表的表名。 |
| table | string | 是 | 指定要查询的数据库表的表名。 |
| columnName | string | 是 | 指定要查询的数据库表的列名。 |
| columnName | string | 是 | 指定要查询的数据库表的列名。 |
| primaryKeys |
[
PRIKeyType
](
#prikeytype10
)[]
| 是 | 指定要查询的行的主键。 |
| primaryKeys |
[
PRIKeyType
](
#prikeytype10
)[]
| 是 | 指定要查询的行的主键。
<br>
如果数据库表无主键,参数columnName需传入"rowid",此时primaryKeys为要查询的数据库表的行号。
<br>
如果数据库表无主键,参数columnName传入不为"rowid",返回对应的错误码。 |
| callback | AsyncCallback
<
[ModifyTime](#modifytime10)
>
| 是 | 指定callback回调函数。如果操作成功,则返回ModifyTime对象,表示数据的最后修改时间。 |
**返回值**
:
| 类型 | 说明 |
| ------------------------------------------ | --------------------------------------------------------- |
| Promise
<
[ModifyTime](#modifytime10)
>
| 返回ModifyTime类型的Promise对象,表示数据最后的修改时间。 |
**错误码:**
**错误码:**
...
@@ -2792,28 +2787,37 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Pro
...
@@ -2792,28 +2787,37 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Pro
**示例:**
**示例:**
```
js
```
js
let
PRIKey
=
[
1
,
2
,
3
];
let
PRIKey
=
[
1
,
4
,
2
,
3
];
relationalStore
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
).
then
((
modifyTime
)
=>
{
relationalStore
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
,
function
(
err
,
modifyTime
)
{
if
(
err
)
{
console
.
error
(
`getModifyTime failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
}
let
size
=
modifyTime
.
size
();
let
size
=
modifyTime
.
size
();
});
});
```
```
### getModifyTime<sup>10+</sup>
### getModifyTime<sup>10+</sup>
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]
, callback: AsyncCallback
<
ModifyTime
>
): void
;
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]
): Promise
<
ModifyTime
>
;
获取数据库表中数据的最后修改时间,使用
callback
异步回调。
获取数据库表中数据的最后修改时间,使用
Promise
异步回调。
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**系统能力:**
SystemCapability.DistributedDataManager.RelationalStore.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------------------------ | ---- | ---------------------------------------------------------- |
| ----------- | ----------------------------- | ---- | ------------------------------------------------------------ |
| table | string | 是 | 指定要查询的数据库表的表名。 |
| table | string | 是 | 指定要查询的数据库表的表名。 |
| columnName | string | 是 | 指定要查询的数据库表的列名。 |
| columnName | string | 是 | 指定要查询的数据库表的列名。 |
| primaryKeys |
[
PRIKeyType
](
#prikeytype10
)[]
| 是 | 指定要查询的行的主键。 |
| primaryKeys |
[
PRIKeyType
](
#prikeytype10
)[]
| 是 | 指定要查询的行的主键。
<br>
如果数据库表无主键,参数columnName需传入"rowid",此时primaryKeys为要查询的数据库表的行号。
<br>
如果数据库表无主键,参数columnName传入不为"rowid",返回对应的错误码。 |
| callback | AsyncCallback
<
[ModifyTime](#modifytime10)
>
| 是 | 指定callback回调函数。如果操作成功,则返回ModifyTime对象,表示数据的最后修改时间。 |
**返回值**
:
| 类型 | 说明 |
| ------------------------------------------ | --------------------------------------------------------- |
| Promise
<
[ModifyTime](#modifytime10)
>
| 返回ModifyTime类型的Promise对象,表示数据最后的修改时间。 |
**错误码:**
**错误码:**
...
@@ -2826,9 +2830,11 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], call
...
@@ -2826,9 +2830,11 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], call
**示例:**
**示例:**
```
js
```
js
let
PRIKey
=
[
1
,
4
,
2
,
3
];
let
PRIKey
=
[
1
,
2
,
3
];
relationalStore
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
,
function
(
err
,
data
)
{
relationalStore
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
).
then
((
modifyTime
)
=>
{
let
size
=
modifyTime
.
size
();
let
size
=
modifyTime
.
size
();
}).
catch
((
err
)
=>
{
console
.
error
(
`getModifyTime failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3485,9 +3491,9 @@ promise.then((result) =>{
...
@@ -3485,9 +3491,9 @@ promise.then((result) =>{
### cloudSync<sup>10+</sup>
### cloudSync<sup>10+</sup>
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
, callback: AsyncCallback
<
void
>
): void
;
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
, callback: AsyncCallback
<
void
>
): void
手动执行端云同步,使用callback异步回调。
手动执行
对所有分布式表的
端云同步,使用callback异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3503,23 +3509,23 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>, callback: A
...
@@ -3503,23 +3509,23 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>, callback: A
**示例:**
**示例:**
```
```
js
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
function
(
ProgressDetails
)
{
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
function
(
ProgressDetails
)
{
console.info(
"Progess: " + '\n' + JSON.stringify(ProgressDetails)
);
console
.
info
(
`Progess:
${
ProgressDetails
}
`
);
},
function
(
err
)
{
},
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Cloud sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
console
.
error
(
`Cloud sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
return
;
}
}
console.info('
cloud sync success.
');
console
.
info
(
'
Cloud sync succeeded
'
);
});
});
```
```
### cloudSync<sup>10+</sup>
### cloudSync<sup>10+</sup>
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
): Promise
<
void
>
;
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
): Promise
<
void
>
手动执行端云同步,使用promise异步回调。
手动执行
对所有分布式表的
端云同步,使用promise异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3540,21 +3546,23 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
...
@@ -3540,21 +3546,23 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
**示例:**
**示例:**
```
```
js
function
Progess
(
ProgressDetail
)
{
function
Progess
(
ProgressDetail
)
{
console.info(
"Progess: " + JSON.stringify(ProgressDetail)
);
console
.
info
(
`Progess:
${
ProgressDetail
}
`
);
}
}
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
Progess
).
then
(()
=>
{
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
Progess
).
then
(()
=>
{
console.info('cloud sync success:');
console
.
info
(
'
Cloud sync succeeded
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`cloudSync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
});
});
```
```
### cloudSync<sup>10+</sup>
### cloudSync<sup>10+</sup>
cloudSync(mode: SyncMode, tables: string[], progress: Callback
<
ProgressDetails
>
, callback: AsyncCallback
<
void
>
): void
;
cloudSync(mode: SyncMode, tables: string[], progress: Callback
<
ProgressDetails
>
, callback: AsyncCallback
<
void
>
): void
手动执行端云同步,使用callback异步回调。
手动执行
对指定表的
端云同步,使用callback异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3571,24 +3579,24 @@ cloudSync(mode: SyncMode, tables: string[], progress: Callback<ProgressDetail
...
@@ -3571,24 +3579,24 @@ cloudSync(mode: SyncMode, tables: string[], progress: Callback<ProgressDetail
**示例:**
**示例:**
```
```
js
const
tables
=
[
"
table1
"
,
"
table2
"
];
const
tables
=
[
"
table1
"
,
"
table2
"
];
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
tables
,
function
(
ProgressDetails
)
{
relationalStore
.
cloudSync
(
relatioanalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
tables
,
function
(
ProgressDetails
)
{
console.info(
"Progess: " + '\n' + JSON.stringify(ProgressDetails)
);
console
.
info
(
`Progess:
${
ProgressDetails
}
`
);
},
function
(
err
)
{
},
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Cloud sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
console
.
error
(
`Cloud sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
return
;
}
}
console.info('
cloud sync success.
');
console
.
info
(
'
Cloud sync succeeded
'
);
});
});
```
```
### cloudSync<sup>10+</sup>
### cloudSync<sup>10+</sup>
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
): Promise
<
void
>
;
cloudSync(mode: SyncMode, progress: Callback
<
ProgressDetails
>
): Promise
<
void
>
手动执行端云同步,使用promise异步回调。
手动执行
对指定表的
端云同步,使用promise异步回调。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
...
@@ -3613,11 +3621,13 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
...
@@ -3613,11 +3621,13 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
```
```
const tables = ["table1", "table2"];
const tables = ["table1", "table2"];
function Progess(ProgressDetail) {
function Progess(ProgressDetail) {
console.info(
"Progess: " + JSON.stringify(ProgressDetail)
);
console.info(
`Progess: ${ProgressDetail}`
);
}
}
relationalStore.cloudSync(relatioanalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, Progess).then(() => {
relationalStore.cloudSync(relatioanalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, Progess).then(() => {
console.info('cloud sync success:');
console.info('Cloud sync succeeded');
}).catch((err) => {
console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
});
});
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录