Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2f03b8ab
D
Docs
项目概览
OpenHarmony
/
Docs
12 个月 前同步成功
通知
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f03b8ab
编写于
1月 28, 2023
作者:
A
Annie_wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
Annie_wang
<
annie.wangli@huawei.com
>
上级
ba08e657
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
20 deletion
+20
-20
en/application-dev/database/database-mdds-guidelines.md
en/application-dev/database/database-mdds-guidelines.md
+20
-20
未找到文件。
en/application-dev/database/database-mdds-guidelines.md
浏览文件 @
2f03b8ab
...
...
@@ -14,12 +14,12 @@ For details about the APIs, see [Distributed KV Store](../reference/apis/js-apis
| API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| createKVManager(config: KVManagerConfig, callback: AsyncCallback
<
KVManager
>
): void
<br>
createKVManager(config: KVManagerConfig): Promise
<
KVManager> | Creates a
**KvManager**
object for database management. |
| getKVStore
<
T
extendsKVStore
>
(storeId: string, options: Options, callback: AsyncCallback
<
T
>
): void
<br>
getKVStore
<
Textends
KVStore
>
(storeId: string, options: Options): Promise
<
T
>
| Creates and obtains a KV store.|
| getKVStore
<
T
extends KVStore
>
(storeId: string, options: Options, callback: AsyncCallback
<
T
>
): void
<br>
getKVStore
<
T extends
KVStore
>
(storeId: string, options: Options): Promise
<
T
>
| Creates and obtains a KV store.|
| put(key: string, value: Uint8Array
\|
string
\|
number
\|
boolean, callback: AsyncCallback
<
void
>
): void
<br>
put(key: string, value: Uint8Array
\|
string
\|
number
\|
boolean): Promise
<
void> | Inserts and updates data. |
| delete(key: string, callback: AsyncCallback
<
void
>
): void
<br>
delete(key: string): Promise
<
void> | Deletes data. |
| get(key: string, callback: AsyncCallback
<
Uint8Array\|string\|boolean\|number
>
): void
<br>
get(key: string): Promise
<
Uint8Array
\|
string
\|
boolean
\|
number> |
Querie
s data. |
| get(key: string, callback: AsyncCallback
<
Uint8Array\|string\|boolean\|number
>
): void
<br>
get(key: string): Promise
<
Uint8Array
\|
string
\|
boolean
\|
number> |
Obtain
s data. |
| on(event: 'dataChange', type: SubscribeType, observer: Callback
<
ChangeNotification
>
): void
<br>
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string,number]
>>
): void | Subscribes to data changes in the KV store. |
| sync(deviceIdList: string[], mode: SyncMode,
allowedD
elayMs?: number): void | Triggers database synchronization in manual mode. |
| sync(deviceIdList: string[], mode: SyncMode,
d
elayMs?: number): void | Triggers database synchronization in manual mode. |
## How to Develop
...
...
@@ -61,32 +61,32 @@ The following uses a single KV store as an example to describe the development p
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => {
console.info('success: ${data}');
}).catch((error) => {
console.
info
('failed: ${error}');
console.
error
('failed: ${error}');
})
}
grantPermission();
// Stage model
import
Ability from '@ohos.application.
Ability';
import
UIAbility from '@ohos.app.ability.UI
Ability';
let context = null;
function grantPermission() {
class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
let context = this.context;
}
}
}
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
context.requestPermissionsFromUser(permissions).then((data) => {
function grantPermission() {
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success: ${data}');
}).catch((error) => {
console.
log
('failed: ${error}');
});
}).catch((error) => {
console.
error
('failed: ${error}');
});
}
grantPermission();
```
...
...
@@ -103,9 +103,9 @@ The following uses a single KV store as an example to describe the development p
let
context
=
featureAbility
.
getContext
();
// Obtain the context of the stage model.
import
AbilityStage from '@ohos.application.
Ability';
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
let
context
=
null
;
class
MainAbility extends AbilityStage
{
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
context
=
this
.
context
;
}
...
...
@@ -119,7 +119,7 @@ The following uses a single KV store as an example to describe the development p
}
distributedKVStore
.
createKVManager
(
kvManagerConfig
,
function
(
err
,
manager
)
{
if
(
err
)
{
console.error(
`Failed to create KVManager.code is ${err.code},message is ${err.message}`
);
console
.
error
(
`Failed to create KVManager.
code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
return
;
}
console
.
log
(
'
Created KVManager successfully
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录