Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b2ea25cb
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b2ea25cb
编写于
2月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
!14447 [翻译完成】#I6AVWY
Merge pull request !14447 from Annie_wang/PR13685
上级
fc9f924f
9d4b9aa0
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
18 deletion
+18
-18
en/application-dev/database/database-mdds-guidelines.md
en/application-dev/database/database-mdds-guidelines.md
+18
-18
未找到文件。
en/application-dev/database/database-mdds-guidelines.md
浏览文件 @
b2ea25cb
...
@@ -14,12 +14,12 @@ For details about the APIs, see [Distributed KV Store](../reference/apis/js-apis
...
@@ -14,12 +14,12 @@ For details about the APIs, see [Distributed KV Store](../reference/apis/js-apis
| API | Description |
| API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| createKVManager(config: KVManagerConfig, callback: AsyncCallback
<
KVManager
>
): void
<br>
createKVManager(config: KVManagerConfig): Promise
<
KVManager> | Creates a
**KvManager**
object for database management. |
| 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. |
| 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. |
| 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. |
| 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
## How to Develop
...
@@ -61,29 +61,29 @@ The following uses a single KV store as an example to describe the development p
...
@@ -61,29 +61,29 @@ The following uses a single KV store as an example to describe the development p
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => {
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666).then((data) => {
console.info('success: ${data}');
console.info('success: ${data}');
}).catch((error) => {
}).catch((error) => {
console.
info
('failed: ${error}');
console.
error
('failed: ${error}');
})
})
}
}
grantPermission();
grantPermission();
// Stage model
// Stage model
import Ability from '@ohos.application.Ability';
import Ability
Stage
from '@ohos.application.Ability';
let context = null;
let context = null;
function grantPermission() {
class MainAbility extends AbilityStage {
class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
onWindowStageCreate(windowStage) {
let context = this.context;
let context = this.context;
}
}
}
}
function grantPermission() {
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
context.requestPermissionsFromUser(permissions).then((data) => {
context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success: ${data}');
console.log('success: ${data}');
}).catch((error) => {
}).catch((error) => {
console.
log
('failed: ${error}');
console.
error
('failed: ${error}');
});
});
}
}
...
@@ -119,7 +119,7 @@ The following uses a single KV store as an example to describe the development p
...
@@ -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
)
{
distributedKVStore
.
createKVManager
(
kvManagerConfig
,
function
(
err
,
manager
)
{
if
(
err
)
{
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
;
return
;
}
}
console
.
log
(
'
Created KVManager successfully
'
);
console
.
log
(
'
Created KVManager successfully
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录