Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
9cf1c4a1
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
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看板
提交
9cf1c4a1
编写于
8月 30, 2023
作者:
M
marui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8.30 modify data
Signed-off-by:
N
marui
<
marui83@huawei.com
>
上级
66e1e1e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
24 deletion
+117
-24
zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
+7
-2
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
...cation-dev/reference/apis/js-apis-data-relationalStore.md
+110
-22
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
浏览文件 @
9cf1c4a1
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
```
js
```
js
import
data_rdb
from
'
@ohos.data.rdb
'
;
import
data_rdb
from
'
@ohos.data.rdb
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
import
window
from
'
@ohos.window
'
;
```
```
## data_rdb.getRdbStore
## data_rdb.getRdbStore
...
@@ -63,6 +61,8 @@ Stage模型示例:
...
@@ -63,6 +61,8 @@ Stage模型示例:
```
ts
```
ts
// 获取context
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
:
Context
;
let
context
:
Context
;
interface
storeConfig
{
interface
storeConfig
{
...
@@ -129,6 +129,8 @@ Stage模型示例:
...
@@ -129,6 +129,8 @@ Stage模型示例:
```
ts
```
ts
// 获取context
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
:
Context
;
let
context
:
Context
;
interface
storeConfig
{
interface
storeConfig
{
...
@@ -190,6 +192,7 @@ Stage模型示例:
...
@@ -190,6 +192,7 @@ Stage模型示例:
```
ts
```
ts
// 获取context
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
let
context
:
Context
;
let
context
:
Context
;
class
EntryAbility
extends
UIAbility
{
class
EntryAbility
extends
UIAbility
{
...
@@ -252,6 +255,8 @@ Stage模型示例:
...
@@ -252,6 +255,8 @@ Stage模型示例:
```
ts
```
ts
// 获取context
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
:
Context
;
let
context
:
Context
;
class
EntryAbility
extends
UIAbility
{
class
EntryAbility
extends
UIAbility
{
...
...
zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md
浏览文件 @
9cf1c4a1
...
@@ -15,11 +15,7 @@
...
@@ -15,11 +15,7 @@
## 导入模块
## 导入模块
```
js
```
js
import
relationalStore
from
'
@ohos.data.relationalStore
'
import
relationalStore
from
'
@ohos.data.relationalStore
'
;
import
window
from
'
@ohos.window
'
;
import
deviceManager
from
'
@ohos.distributedHardware.deviceManager
'
;
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
```
```
## relationalStore.getRdbStore
## relationalStore.getRdbStore
...
@@ -56,7 +52,8 @@ FA模型示例:
...
@@ -56,7 +52,8 @@ FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -81,7 +78,9 @@ relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdb
...
@@ -81,7 +78,9 @@ relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdb
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
class
EntryAbility
extends
UIAbility
{
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
...
@@ -141,7 +140,8 @@ getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>
...
@@ -141,7 +140,8 @@ getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>
FA模型示例:
FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -165,7 +165,9 @@ promise.then(async (rdbStore: relationalStore.RdbStore) => {
...
@@ -165,7 +165,9 @@ promise.then(async (rdbStore: relationalStore.RdbStore) => {
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
class
EntryAbility
extends
UIAbility
{
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
...
@@ -218,7 +220,8 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void&g
...
@@ -218,7 +220,8 @@ deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void&g
FA模型示例:
FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -238,7 +241,9 @@ relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError)
...
@@ -238,7 +241,9 @@ relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError)
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -293,7 +298,8 @@ deleteRdbStore(context: Context, name: string): Promise<void>
...
@@ -293,7 +298,8 @@ deleteRdbStore(context: Context, name: string): Promise<void>
FA模型示例:
FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -312,7 +318,9 @@ promise.then(()=>{
...
@@ -312,7 +318,9 @@ promise.then(()=>{
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -363,7 +371,8 @@ deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<v
...
@@ -363,7 +371,8 @@ deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<v
FA模型示例:
FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -387,7 +396,9 @@ relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError)
...
@@ -387,7 +396,9 @@ relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError)
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -448,7 +459,8 @@ deleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
...
@@ -448,7 +459,8 @@ deleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
FA模型示例:
FA模型示例:
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -471,7 +483,9 @@ promise.then(()=>{
...
@@ -471,7 +483,9 @@ promise.then(()=>{
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
store
:
relationalStore
.
RdbStore
;
let
store
:
relationalStore
.
RdbStore
;
...
@@ -1680,6 +1694,8 @@ insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>
...
@@ -1680,6 +1694,8 @@ insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -1732,6 +1748,8 @@ insert(table: string, values: ValuesBucket, conflict: ConflictResolution, callb
...
@@ -1732,6 +1748,8 @@ insert(table: string, values: ValuesBucket, conflict: ConflictResolution, callb
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -1788,6 +1806,9 @@ insert(table: string, values: ValuesBucket):Promise<number>
...
@@ -1788,6 +1806,9 @@ insert(table: string, values: ValuesBucket):Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -1844,6 +1865,9 @@ insert(table: string, values: ValuesBucket, conflict: ConflictResolution):Promi
...
@@ -1844,6 +1865,9 @@ insert(table: string, values: ValuesBucket, conflict: ConflictResolution):Promi
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -1894,6 +1918,8 @@ batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCal
...
@@ -1894,6 +1918,8 @@ batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCal
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -1972,6 +1998,9 @@ batchInsert(table: string, values: Array<ValuesBucket>):Promise<number&
...
@@ -1972,6 +1998,9 @@ batchInsert(table: string, values: Array<ValuesBucket>):Promise<number&
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2044,6 +2073,8 @@ update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback&
...
@@ -2044,6 +2073,8 @@ update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback&
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2098,6 +2129,8 @@ update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolu
...
@@ -2098,6 +2129,8 @@ update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolu
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2156,6 +2189,9 @@ update(values: ValuesBucket, predicates: RdbPredicates):Promise<number>
...
@@ -2156,6 +2189,9 @@ update(values: ValuesBucket, predicates: RdbPredicates):Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2214,6 +2250,9 @@ update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolu
...
@@ -2214,6 +2250,9 @@ update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolu
**示例:**
**示例:**
```
js
```
js
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2272,6 +2311,8 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data
...
@@ -2272,6 +2311,8 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data
```
js
```
js
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2335,7 +2376,10 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data
...
@@ -2335,7 +2376,10 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data
**示例:**
**示例:**
```
js
```
js
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
key1
=
"
NAME
"
;
let
key1
=
"
NAME
"
;
let
key2
=
"
AGE
"
;
let
key2
=
"
AGE
"
;
let
key3
=
"
SALARY
"
;
let
key3
=
"
SALARY
"
;
...
@@ -2430,6 +2474,8 @@ delete(predicates: RdbPredicates):Promise<number>
...
@@ -2430,6 +2474,8 @@ delete(predicates: RdbPredicates):Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
predicates
=
new
relationalStore
.
RdbPredicates
(
"
EMPLOYEE
"
);
let
predicates
=
new
relationalStore
.
RdbPredicates
(
"
EMPLOYEE
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Lisa
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Lisa
"
);
let
promise
=
store
.
delete
(
predicates
);
let
promise
=
store
.
delete
(
predicates
);
...
@@ -2521,7 +2567,9 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promi
...
@@ -2521,7 +2567,9 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promi
**示例:**
**示例:**
```
js
```
js
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
"
NAME
"
,
"
Lisa
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Lisa
"
);
let
promise
=
store
.
delete
(
"
EMPLOYEE
"
,
predicates
);
let
promise
=
store
.
delete
(
"
EMPLOYEE
"
,
predicates
);
...
@@ -2658,7 +2706,9 @@ query(predicates: RdbPredicates, columns?: Array<string>):Promise<Resul
...
@@ -2658,7 +2706,9 @@ query(predicates: RdbPredicates, columns?: Array<string>):Promise<Resul
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
predicates
=
new
relationalStore
.
RdbPredicates
(
"
EMPLOYEE
"
);
let
predicates
=
new
relationalStore
.
RdbPredicates
(
"
EMPLOYEE
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Rose
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Rose
"
);
let
promise
=
store
.
query
(
predicates
,
[
"
ID
"
,
"
NAME
"
,
"
AGE
"
,
"
SALARY
"
,
"
CODES
"
]);
let
promise
=
store
.
query
(
predicates
,
[
"
ID
"
,
"
NAME
"
,
"
AGE
"
,
"
SALARY
"
,
"
CODES
"
]);
...
@@ -2677,7 +2727,7 @@ promise.then((resultSet: relationalStore.ResultSet) => {
...
@@ -2677,7 +2727,7 @@ promise.then((resultSet: relationalStore.ResultSet) => {
}).
catch
((
err
:
BusinessError
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Query failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
console
.
error
(
`Query failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
})
})
```
```
### query<sup>10+</sup>
### query<sup>10+</sup>
...
@@ -2823,7 +2873,9 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column
...
@@ -2823,7 +2873,9 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column
**示例:**
**示例:**
```
js
```
js
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
"
NAME
"
,
"
Rose
"
);
predicates
.
equalTo
(
"
NAME
"
,
"
Rose
"
);
let
promise
=
store
.
query
(
"
EMPLOYEE
"
,
predicates
,
[
"
ID
"
,
"
NAME
"
,
"
AGE
"
,
"
SALARY
"
,
"
CODES
"
]);
let
promise
=
store
.
query
(
"
EMPLOYEE
"
,
predicates
,
[
"
ID
"
,
"
NAME
"
,
"
AGE
"
,
"
SALARY
"
,
"
CODES
"
]);
...
@@ -2878,6 +2930,8 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
...
@@ -2878,6 +2930,8 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
```
js
```
js
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
deviceId
:
string
=
null
;
let
deviceId
:
string
=
null
;
...
@@ -2948,6 +3002,8 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
...
@@ -2948,6 +3002,8 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
```
js
```
js
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
deviceId
:
string
=
null
;
let
deviceId
:
string
=
null
;
...
@@ -3102,6 +3158,8 @@ querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet>
...
@@ -3102,6 +3158,8 @@ querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
promise
=
store
.
querySql
(
"
SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'
"
);
let
promise
=
store
.
querySql
(
"
SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'
"
);
promise
.
then
((
resultSet
:
relationalStore
.
ResultSet
)
=>
{
promise
.
then
((
resultSet
:
relationalStore
.
ResultSet
)
=>
{
console
.
info
(
`ResultSet column names:
${
resultSet
.
columnNames
}
, column count:
${
resultSet
.
columnCount
}
`
);
console
.
info
(
`ResultSet column names:
${
resultSet
.
columnNames
}
, column count:
${
resultSet
.
columnCount
}
`
);
...
@@ -3228,6 +3286,8 @@ executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void>
...
@@ -3228,6 +3286,8 @@ executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
const
SQL_DELETE_TABLE
=
"
DELETE FROM test WHERE name = 'zhangsan'
"
const
SQL_DELETE_TABLE
=
"
DELETE FROM test WHERE name = 'zhangsan'
"
let
promise
=
store
.
executeSql
(
SQL_DELETE_TABLE
);
let
promise
=
store
.
executeSql
(
SQL_DELETE_TABLE
);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
...
@@ -3308,6 +3368,8 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Pro
...
@@ -3308,6 +3368,8 @@ getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Pro
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
PRIKey
=
[
1
,
2
,
3
];
let
PRIKey
=
[
1
,
2
,
3
];
store
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
).
then
((
modifyTime
:
relationalStore
.
ModifyTime
)
=>
{
store
.
getModifyTime
(
"
cloud_tasks
"
,
"
uuid
"
,
PRIKey
).
then
((
modifyTime
:
relationalStore
.
ModifyTime
)
=>
{
let
size
=
modifyTime
.
size
;
let
size
=
modifyTime
.
size
;
...
@@ -3337,6 +3399,8 @@ beginTransaction():void
...
@@ -3337,6 +3399,8 @@ beginTransaction():void
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
let
key1
=
"
name
"
;
let
key1
=
"
name
"
;
let
key2
=
"
age
"
;
let
key2
=
"
age
"
;
...
@@ -3379,6 +3443,8 @@ commit():void
...
@@ -3379,6 +3443,8 @@ commit():void
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
let
key1
=
"
name
"
;
let
key1
=
"
name
"
;
let
key2
=
"
age
"
;
let
key2
=
"
age
"
;
...
@@ -3421,6 +3487,8 @@ rollBack():void
...
@@ -3421,6 +3487,8 @@ rollBack():void
```
js
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
;
let
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
let
key1
=
"
name
"
;
let
key1
=
"
name
"
;
let
key2
=
"
age
"
;
let
key2
=
"
age
"
;
...
@@ -3522,6 +3590,8 @@ backup(destName:string): Promise<void>
...
@@ -3522,6 +3590,8 @@ backup(destName:string): Promise<void>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
promiseBackup
=
store
.
backup
(
"
dbBackup.db
"
);
let
promiseBackup
=
store
.
backup
(
"
dbBackup.db
"
);
promiseBackup
.
then
(()
=>
{
promiseBackup
.
then
(()
=>
{
console
.
info
(
`Backup success.`
);
console
.
info
(
`Backup success.`
);
...
@@ -3596,6 +3666,8 @@ restore(srcName:string): Promise<void>
...
@@ -3596,6 +3666,8 @@ restore(srcName:string): Promise<void>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
promiseRestore
=
store
.
restore
(
"
dbBackup.db
"
);
let
promiseRestore
=
store
.
restore
(
"
dbBackup.db
"
);
promiseRestore
.
then
(()
=>
{
promiseRestore
.
then
(()
=>
{
console
.
info
(
`Restore success.`
);
console
.
info
(
`Restore success.`
);
...
@@ -3674,6 +3746,8 @@ store.setDistributedTables(["EMPLOYEE"], (err) => {
...
@@ -3674,6 +3746,8 @@ store.setDistributedTables(["EMPLOYEE"], (err) => {
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
]);
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
]);
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
`SetDistributedTables successfully.`
);
console
.
info
(
`SetDistributedTables successfully.`
);
...
@@ -3801,6 +3875,8 @@ store.setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIB
...
@@ -3801,6 +3875,8 @@ store.setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIB
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
relationalStore
.
DistributedType
.
DISTRIBUTED_CLOUD
,
{
let
promise
=
store
.
setDistributedTables
([
"
EMPLOYEE
"
],
relationalStore
.
DistributedType
.
DISTRIBUTED_CLOUD
,
{
autoSync
:
true
autoSync
:
true
});
});
...
@@ -3904,6 +3980,8 @@ store.obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
...
@@ -3904,6 +3980,8 @@ store.obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
```
js
```
js
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
deviceId
:
string
=
null
;
let
deviceId
:
string
=
null
;
...
@@ -4015,6 +4093,8 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) =>
...
@@ -4015,6 +4093,8 @@ store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) =>
```
js
```
js
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
deviceIds
:
Array
<
string
>
=
[];
let
deviceIds
:
Array
<
string
>
=
[];
...
@@ -4099,6 +4179,8 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
...
@@ -4099,6 +4179,8 @@ cloudSync(mode: SyncMode, progress: Callback<ProgressDetails>): Promise<
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
store
.
cloudSync
(
relationalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
(
progressDetail
:
relationalStore
.
ProgressDetails
)
=>
{
store
.
cloudSync
(
relationalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
(
progressDetail
:
relationalStore
.
ProgressDetails
)
=>
{
console
.
info
(
`progress:
${
progressDetail
}
`
);
console
.
info
(
`progress:
${
progressDetail
}
`
);
}).
then
(()
=>
{
}).
then
(()
=>
{
...
@@ -4169,6 +4251,8 @@ cloudSync(mode: SyncMode, tables: string[], progress: Callback<ProgressDetail
...
@@ -4169,6 +4251,8 @@ cloudSync(mode: SyncMode, tables: string[], progress: Callback<ProgressDetail
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
"
@ohos.base
"
;
const
tables
=
[
"
table1
"
,
"
table2
"
];
const
tables
=
[
"
table1
"
,
"
table2
"
];
store
.
cloudSync
(
relationalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
(
progressDetail
:
relationalStore
.
ProgressDetails
)
=>
{
store
.
cloudSync
(
relationalStore
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
(
progressDetail
:
relationalStore
.
ProgressDetails
)
=>
{
...
@@ -4199,6 +4283,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
...
@@ -4199,6 +4283,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
**示例:**
**示例:**
```
js
```
js
import
deviceManager
from
'
@ohos.distributedHardware.deviceManager
'
;
try
{
try
{
store
.
on
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
(
storeObserver
)
=>
{
store
.
on
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
(
storeObserver
)
=>
{
let
devices
:
string
;
let
devices
:
string
;
...
@@ -4231,6 +4316,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
...
@@ -4231,6 +4316,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
**示例:**
**示例:**
```
js
```
js
import
deviceManager
from
'
@ohos.distributedHardware.deviceManager
'
;
function
storeObserver
(
devices
)
{
function
storeObserver
(
devices
)
{
for
(
let
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
console
.
info
(
`device=
${
devices
[
i
]}
data changed`
);
console
.
info
(
`device=
${
devices
[
i
]}
data changed`
);
...
@@ -4299,6 +4385,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
...
@@ -4299,6 +4385,7 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
**示例:**
**示例:**
```
```
import deviceManager from '@ohos.distributedHardware.deviceManager';
try {
try {
store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
let devices: string;
let devices: string;
...
@@ -4331,6 +4418,7 @@ off(event:'dataChange', type: SubscribeType, observer?: Callback<Array<str
...
@@ -4331,6 +4418,7 @@ off(event:'dataChange', type: SubscribeType, observer?: Callback<Array<str
**示例:**
**示例:**
```
js
```
js
import
deviceManager
from
'
@ohos.distributedHardware.deviceManager
'
;
try
{
try
{
store
.
off
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
(
storeObserver
)
=>
{
store
.
off
(
'
dataChange
'
,
relationalStore
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
(
storeObserver
)
=>
{
let
devices
:
string
;
let
devices
:
string
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录