From 2f03b8ab40a2332c84c93bff17610c2432c90cdb Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Sat, 28 Jan 2023 16:28:25 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../database/database-mdds-guidelines.md | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index 73f785de4d..b72874536b 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -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
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KvManager** object for database management. | -| getKVStore<TextendsKVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<TextendsKVStore>(storeId: string, options: Options): Promise<T> | Creates and obtains a KV store.| +| getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
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
put(key: string, value: Uint8Array\|string\|number\|boolean): Promise<void> | Inserts and updates data. | | delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. | -| get(key: string, callback: AsyncCallback<Uint8Array\|string\|boolean\|number>): void
get(key: string): Promise<Uint8Array\|string\|boolean\|number> | Queries data. | +| get(key: string, callback: AsyncCallback<Uint8Array\|string\|boolean\|number>): void
get(key: string): Promise<Uint8Array\|string\|boolean\|number> | Obtains data. | | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string,number]>>): void | Subscribes to data changes in the KV store. | -| sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | +| sync(deviceIdList: string[], mode: SyncMode, delayMs?: 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.UIAbility'; 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.UIAbility'; 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'); -- GitLab