Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c0af92a1
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看板
提交
c0af92a1
编写于
3月 08, 2023
作者:
A
Annie_wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
c44ad77a
from
https://gitee.com/Annie_wang/docs/pulls/15657
update docs Signed-off-by:
N
Annie_wang
<
annie.wangli@huawei.com
>
上级
8f20ac7f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
21 deletion
+15
-21
en/application-dev/database/database-mdds-guidelines.md
en/application-dev/database/database-mdds-guidelines.md
+15
-21
未找到文件。
en/application-dev/database/database-mdds-guidelines.md
浏览文件 @
c0af92a1
...
...
@@ -13,7 +13,7 @@ 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. |
| createKVManager(config: KVManagerConfig
): KVManager
| Creates a
**KvManager**
object for database management. |
| 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. |
...
...
@@ -117,16 +117,10 @@ The following uses a single KV store as an example to describe the development p
bundleName: 'com.example.datamanagertest',
context:context,
}
distributedKVStore.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.error(
`Failed to create KVManager. code is ${err.code},message is ${err.message}`
);
return;
}
console.log('Created KVManager successfully');
kvManager = manager;
});
kvManager = distributedKVStore.createKVManager(kvManagerConfig);
console.log("Created KVManager successfully");
} catch (e) {
console.error(
`
An unexpected error occurred.code is ${e.code},
message is ${e.message}`
);
console.error(
`
Failed to create KVManager. Code is ${e.code},
message is ${e.message}`
);
}
```
...
...
@@ -150,14 +144,14 @@ The following uses a single KV store as an example to describe the development p
};
kvManager.getKVStore('storeId', options, function (err, store) {
if (err) {
console.error(
`Failed to get KVStore: code is ${err.code},message is ${err.message}`
);
console.error(
`Failed to get KVStore: code is ${err.code},
message is ${err.message}`
);
return;
}
console.log('Obtained KVStore successfully');
kvStore = store;
});
} catch (e) {
console.error(
`An unexpected error occurred.
code is ${e.code},
message is ${e.message}`
);
console.error(
`An unexpected error occurred.
Code is ${e.code},
message is ${e.message}`
);
}
```
...
...
@@ -175,7 +169,7 @@ The following uses a single KV store as an example to describe the development p
console.log(
`dataChange callback call data: ${data}`
);
});
}catch(e){
console.error(
`An unexpected error occured.
code is ${e.code},
message is ${e.message}`
);
console.error(
`An unexpected error occured.
Code is ${e.code},
message is ${e.message}`
);
}
```
...
...
@@ -192,13 +186,13 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
console.error(
`Failed to put
.code is ${err.code},
message is ${err.message}`
);
console.error(
`Failed to put
data. Code is ${err.code},
message is ${err.message}`
);
return;
}
console.log(
'Put data successfully'
);
console.log(
"Put data successfully"
);
});
}catch (e) {
console.error(
`An unexpected error occurred.
code is ${e.code},
message is ${e.message}`
);
console.error(
`An unexpected error occurred.
Code is ${e.code},
message is ${e.message}`
);
}
```
...
...
@@ -215,20 +209,20 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
console.error(
`Failed to put
.code is ${err.code},
message is ${err.message}`
);
console.error(
`Failed to put
data. Code is ${err.code},
message is ${err.message}`
);
return;
}
console.log(
'Put data successfully'
);
console.log(
"Put data successfully"
);
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
console.error(
`Failed to
get data.code is ${err.code},
message is ${err.message}`
);
console.error(
`Failed to
obtain data. Code is ${err.code},
message is ${err.message}`
);
return;
}
console.log(
`Obtained data successfully:${data}`
);
});
});
}catch (e) {
console.error(
`Failed to
get.code is ${e.code},
message is ${e.message}`
);
console.error(
`Failed to
obtain data. Code is ${e.code},
message is ${e.message}`
);
}
```
...
...
@@ -262,7 +256,7 @@ The following uses a single KV store as an example to describe the development p
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedKVStore.SyncMode.PUSH_ONLY, 1000);
} catch (e) {
console.error(
`An unexpected error occurred.
code is ${e.code},
message is ${e.message}`
);
console.error(
`An unexpected error occurred.
Code is ${e.code},
message is ${e.message}`
);
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录