diff --git a/api/@ohos.data.distributedData.d.ts b/api/@ohos.data.distributedData.d.ts index e020a0403156886ce840b91c9e0a6fcb6cf666f1..9231cbc643dcd839ff67ccdbdc9a9f4e8ed299ec 100644 --- a/api/@ohos.data.distributedData.d.ts +++ b/api/@ohos.data.distributedData.d.ts @@ -14,51 +14,40 @@ */ import { AsyncCallback, Callback } from './basic'; -import { ValuesBucket } from './@ohos.data.ValuesBucket'; -import dataSharePredicates from './@ohos.data.dataSharePredicates'; -import DataShareResultSet from './@ohos.data.DataShareResultSet'; -import Context from './application/Context'; /** * Providers interfaces to creat a {@link KVManager} istances. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore */ - declare namespace distributedData { /** * Provides configuration information for {@link KVManager} instances, * including the caller's package name and distributed network type. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManagerConfig */ interface KVManagerConfig { /** * Indicates the user information - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userInfo: UserInfo; /** * Indicates the bundleName - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManagerConfig#bundleName */ bundleName: string; - - /** - * Indicates the ability or hap context - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @Note: if swap the area, you should close all the KV store and use the new Context to create the KVManager - */ - context: Context; } /** @@ -67,24 +56,24 @@ declare namespace distributedData { *

This class provides methods for obtaining the user ID and type, setting the user ID and type, * and checking whether two users are the same. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ interface UserInfo { /** * Indicates the user ID to set - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userId?: string; /** * Indicates the user type to set - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userType?: UserType; } @@ -92,72 +81,80 @@ declare namespace distributedData { /** * Enumerates user types. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ enum UserType { /** * Indicates a user that logs in to different devices using the same account. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ SAME_USER_ID = 0 } /** * KVStore constants - * @since 7 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants */ namespace Constants { /** * max key length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH */ const MAX_KEY_LENGTH = 1024; /** * max value length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_VALUE_LENGTH */ const MAX_VALUE_LENGTH = 4194303; /** * max device coordinate key length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH_DEVICEs */ const MAX_KEY_LENGTH_DEVICE = 896; /** * max store id length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_STORE_ID_LENGTH */ const MAX_STORE_ID_LENGTH = 128; /** * max query length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_QUERY_LENGTH */ const MAX_QUERY_LENGTH = 512000; /** * max batch operation size. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_BATCH_SIZE */ const MAX_BATCH_SIZE = 128; } @@ -167,56 +164,63 @@ declare namespace distributedData { * *

{@code ValueType} is obtained based on the value. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType */ enum ValueType { /** * Indicates that the value type is string. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#STRING */ STRING = 0, /** * Indicates that the value type is int. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#INTEGER */ INTEGER = 1, /** * Indicates that the value type is float. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#FLOAT */ FLOAT = 2, /** * Indicates that the value type is byte array. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueTypeB#YTE_ARRAY * */ BYTE_ARRAY = 3, /** * Indicates that the value type is boolean. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#BOOLEAN * */ BOOLEAN = 4, /** * Indicates that the value type is double. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#DOUBLE */ DOUBLE = 5 } @@ -224,26 +228,29 @@ declare namespace distributedData { /** * Obtains {@code Value} objects stored in a {@link KVStore} database. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value */ interface Value { /** * Indicates value type - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @see ValueType * @type {number} * @memberof Value + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value#type */ type: ValueType; /** * Indicates value - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value#value */ value: Uint8Array | string | number | boolean; } @@ -251,23 +258,26 @@ declare namespace distributedData { /** * Provides key-value pairs stored in the distributed database. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry */ interface Entry { /** * Indicates key - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry#key */ key: string; /** * Indicates value - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry#value */ value: Value; } @@ -278,37 +288,42 @@ declare namespace distributedData { *

If you have subscribed to {@code KVStore}, you will receive data change notifications and obtain the changed data * from the parameters in callback methods upon data insertion, update, or deletion. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification */ interface ChangeNotification { /** * Indicates data addition records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#insertEntries */ insertEntries: Entry[]; /** * Indicates data update records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#updateEntries */ updateEntries: Entry[]; /** * Indicates data deletion records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#deleteEntries */ deleteEntries: Entry[]; /** * Indicates from device id. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#deviceId */ deviceId: string; } @@ -316,30 +331,34 @@ declare namespace distributedData { /** * Indicates the database synchronization mode. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode */ enum SyncMode { /** * Indicates that data is only pulled from the remote end. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PULL_ONLY */ PULL_ONLY = 0, /** * Indicates that data is only pushed from the local end. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_ONLY */ PUSH_ONLY = 1, /** * Indicates that data is pushed from the local end, and then pulled from the remote end. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_PULL */ PUSH_PULL = 2 } @@ -347,32 +366,36 @@ declare namespace distributedData { /** * Describes the subscription type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType */ enum SubscribeType { /** * Subscription to local data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_LOCAL */ SUBSCRIBE_TYPE_LOCAL = 0, /** * Subscription to remote data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_REMOTE */ SUBSCRIBE_TYPE_REMOTE = 1, /** * Subscription to both local and remote data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_ALL */ SUBSCRIBE_TYPE_ALL = 2, } @@ -380,32 +403,35 @@ declare namespace distributedData { /** * Describes the {@code KVStore} type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType */ enum KVStoreType { /** * Device-collaborated database, as specified by {@code DeviceKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType#DEVICE_COLLABORATION */ DEVICE_COLLABORATION = 0, /** * Single-version database, as specified by {@code SingleKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType#SINGLE_VERSION */ SINGLE_VERSION = 1, /** * Multi-version database, as specified by {@code MultiKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 */ MULTI_VERSION = 2, } @@ -413,17 +439,18 @@ declare namespace distributedData { /** * Describes the {@code KVStore} type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel */ enum SecurityLevel { /** * NO_LEVEL: mains not set the security level. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 */ NO_LEVEL = 0, @@ -431,9 +458,9 @@ declare namespace distributedData { * S0: mains the db is public. * There is no impact even if the data is leaked. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ S0 = 1, @@ -441,9 +468,10 @@ declare namespace distributedData { * S1: mains the db is low level security * There are some low impact, when the data is leaked. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S1 */ S1 = 2, @@ -451,9 +479,10 @@ declare namespace distributedData { * S2: mains the db is middle level security * There are some major impact, when the data is leaked. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S2 */ S2 = 3, @@ -461,9 +490,10 @@ declare namespace distributedData { * S3: mains the db is high level security * There are some severity impact, when the data is leaked. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S3 */ S3 = 5, @@ -471,9 +501,10 @@ declare namespace distributedData { * S4: mains the db is critical level security * There are some critical impact, when the data is leaked. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S4 */ S4 = 6, } @@ -484,59 +515,67 @@ declare namespace distributedData { *

You can determine whether to create another database if a {@code KVStore} database is missing, * whether to encrypt the database, and the database type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options */ interface Options { /** * Indicates whether to createa database when the database file does not exist - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#createIfMissing */ createIfMissing?: boolean; /** * Indicates setting whether database files are encrypted - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#encrypt */ encrypt?: boolean; /** * Indicates setting whether to back up database files - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#backup */ backup?: boolean; /** * Indicates setting whether database files are automatically synchronized - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @permission ohos.permission.DISTRIBUTED_DATASYNC - * @import N/A + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#autoSync */ autoSync?: boolean; /** * Indicates setting the databse type - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#kvStoreType */ kvStoreType?: KVStoreType; /** * Indicates setting the database security level - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#securityLevel */ securityLevel?: SecurityLevel; /** * Indicates schema object - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#schema */ schema?: Schema; } @@ -546,44 +585,55 @@ declare namespace distributedData { * * You can create Schema objects and put them in Options when creating or opening the database. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema */ class Schema { /** * A constructor used to create a Schema instance. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#constructor */ constructor() /** * Indicates the root json object. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#root */ root: FieldNode; /** * Indicates the string array of json. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#indexes */ indexes: Array; /** * Indicates the mode of schema. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#mode */ mode: number; /** * Indicates the skipsize of schema. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#skip */ skip: number; } @@ -597,17 +647,20 @@ declare namespace distributedData { * *

The leaf node must have a value; the non-leaf node must have a child {@code FieldNode}. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode */ class FieldNode { /** * A constructor used to create a FieldNode instance with the specified field. * name Indicates the field node name. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#constructor */ constructor(name: string) /** @@ -615,31 +668,39 @@ declare namespace distributedData { * *

Adding a child node makes this node a non-leaf node. Field value will be ignored if it has child node. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @param child The field node to append. + * @param child The field node to append. * @returns Returns true if the child node is successfully added to this {@code FieldNode}; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#appendChild */ appendChild(child: FieldNode): boolean; /** * Indicates the default value of fieldnode. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#default */ default: string; /** * Indicates the nullable of database field. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#nullable */ nullable: boolean; /** * Indicates the type of value. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#type */ type: number; } @@ -650,434 +711,494 @@ declare namespace distributedData { *

The result set is created by using the {@code getResultSet} method in the {@code DeviceKVStore} class. This interface also provides * methods for moving the data read position in the result set. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet */ interface KvStoreResultSet { /** * Obtains the number of lines in a result set. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns the number of lines. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getCount */ getCount(): number; /** * Obtains the current read position in a result set. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns the current read position. The read position starts with 0. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getPosition */ getPosition(): number; /** * Moves the read position to the first line. * *

If the result set is empty, false is returned. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToFirst */ moveToFirst(): boolean; /** * Moves the read position to the last line. * *

If the result set is empty, false is returned. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToLast */ moveToLast(): boolean; /** * Moves the read position to the next line. * *

If the result set is empty or the data in the last line is being read, false is returned. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToNext */ moveToNext(): boolean; /** * Moves the read position to the previous line. * *

If the result set is empty or the data in the first line is being read, false is returned. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPrevious */ moveToPrevious(): boolean; /** * Moves the read position by a relative offset to the current position. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param offset Indicates the relative offset to the current position. Anegative offset indicates moving backwards, and a * positive offset indicates moving forewards. Forexample, if the current position is entry 1 and thisoffset is 2, * the destination position will be entry 3; ifthe current position is entry 3 and this offset is -2, * the destination position will be entry 1. The valid final position after moving forwards starts with 0. If the * final position is invalid, false will be returned. * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#move */ move(offset: number): boolean; /** * Moves the read position from 0 to an absolute position. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param position Indicates the absolute position. * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPosition */ moveToPosition(position: number): boolean; /** * Checks whether the read position is the first line. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @returns Returns true if the read position is the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isFirst */ isFirst(): boolean; /** * Checks whether the read position is the last line. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns true if the read position is the last line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isLast */ isLast(): boolean; /** * Checks whether the read position is before the last line. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns true if the read position is before the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isBeforeFirst */ isBeforeFirst(): boolean; /** * Checks whether the read position is after the last line. * - * @since 8 + * @returns Returns true if the read position is after the last line; returns false otherwise. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @returns Returns true if the read position is after the last line; returns false otherwise. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isAfterLast */ isAfterLast(): boolean; /** * Obtains a key-value pair. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns a key-value pair. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getEntry */ getEntry(): Entry; } /** * Represents a database query using a predicate. - * + * *

This class provides a constructor used to create a {@code Query} instance, which is used to query data matching specified * conditions in the database. - * + * *

This class also provides methods for adding predicates to the {@code Query} instance. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query */ class Query { /** * A constructor used to create a Query instance. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#constructor */ - constructor() + constructor() /** * Resets this {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @returns Returns the reset {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#reset */ reset(): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value IIndicates the long value. * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#equalTo */ equalTo(field: string, value: number|string|boolean): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is not equal to the specified int value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the int value. * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notEqualTo */ notEqualTo(field: string, value: number|string|boolean): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the * specified int value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the int value. * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#greaterThan */ greaterThan(field: string, value: number|string|boolean): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is less than the specified int value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the int value. * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. - */ + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#lessThan + */ lessThan(field: string, value: number|string): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the * specified int value. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the int value. * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#greaterThanOrEqualTo */ greaterThanOrEqualTo(field: string, value: number|string): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is less than or equal to the * specified int value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the int value. - * @returns Returns the {@coed Query} object. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#lessThanOrEqualTo */ lessThanOrEqualTo(field: string, value: number|string): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is null. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. - * @returns Returns the {@coed Query} object. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#isNull */ isNull(field: string): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified int value list. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param valueList Indicates the int value list. - * @returns Returns the {@coed Query} object. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#inNumber */ inNumber(field: string, valueList: number[]): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified string value list. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param valueList Indicates the string value list. - * @returns Returns the {@coed Query} object. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#inString */ inString(field: string, valueList: string[]): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified int value list. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param valueList Indicates the int value list. * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notInNumber */ notInNumber(field: string, valueList: number[]): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified string value list. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param valueList Indicates the string value list. - * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notInString */ notInString(field: string, valueList: string[]): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is similar to the specified string value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the string value. - * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#like */ like(field: string, value: string): Query; /** * Constructs a {@code Query} object to query entries with the specified field whose value is not similar to the specified string value. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @param value Indicates the string value. - * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#unlike */ unlike(field: string, value: string): Query; /** * Constructs a {@code Query} object with the and condition. - * + * *

Multiple predicates should be connected using the and or or condition. - * - * @since 8 + * + * @returns Returns the {@coed Query} object. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @returns Returns the {@coed Query} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#and */ and(): Query; /** * Constructs a {@code Query} object with the or condition. - * + * *

Multiple predicates should be connected using the and or or condition. - * - * @since 8 + * + * @returns Returns the {@coed Query} object. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @returns Returns the {@coed Query} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#or */ or(): Query; /** * Constructs a {@code Query} object to sort the query results in ascending order. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. - * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#orderByAsc */ orderByAsc(field: string): Query; /** * Constructs a {@code Query} object to sort the query results in descending order. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the field, which must start with $. and cannot contain ^. * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#orderByDesc */ orderByDesc(field: string): Query; /** * Constructs a {@code Query} object to specify the number of results and the start position. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param total Indicates the number of results. * @param offset Indicates the start position. * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#limit */ limit(total: number, offset: number): Query; /** * Creates a {@code query} condition with a specified field that is not null. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param field Indicates the specified field. * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#isNotNull */ isNotNull(field: string): Query; /** * Creates a query condition group with a left bracket. - * + * *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a * whole to combine with other query conditions. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#beginGroup */ beginGroup(): Query; /** * Creates a query condition group with a right bracket. - * + * *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a * whole to combine with other query conditions. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#endGroup */ endGroup(): Query; /** * Creates a query condition with a specified key prefix. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param prefix Indicates the specified key prefix. * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#prefixKey */ prefixKey(prefix: string): Query; /** * Sets a specified index that will be preferentially used for query. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @param index Indicates the index to set. * @returns Returns the {@coed Query} object. - * @throws Throws this exception if input is invalid. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#setSuggestIndex */ setSuggestIndex(index: string): Query; /** * Add device ID key prefix.Used by {@code DeviceKVStore}. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @param deviceId Specify device id to query from. * @return Returns the {@code Query} object with device ID prefix added. * @throw Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#deviceId */ deviceId(deviceId:string):Query; /** @@ -1085,11 +1206,12 @@ declare namespace distributedData { * *

The String would be parsed to DB query format. * The String length should be no longer than 500kb. - * - * @since 8 + * + * @return String representing this {@code Query}. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @return String representing this {@code Query}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#getSqlLike */ getSqlLike():string; } @@ -1102,227 +1224,182 @@ declare namespace distributedData { * with input parameter {@code Options}. Distributed database types are defined in {@code KVStoreType}, * including {@code SingleKVStore}. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @version 1 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore */ interface KVStore { /** * Writes a key-value pair of the string type into the {@code KvStore} database. * *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. - * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. * Spaces before and after the key will be cleared. * @param value Indicates the string value, which must be less than 4 MB as a UTF-8 byte array. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#put */ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; put(key: string, value: Uint8Array | string | number | boolean): Promise; - /** - * Writes a value of the valuesbucket type into the {@code KvStore} database. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @systemapi - * @param value Indicates the data record to put. - * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. - */ - putBatch(value: Array, callback: AsyncCallback): void; - putBatch(value: Array): Promise; - /** * Deletes the key-value pair based on a specified key. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors + * @throws Throws this exception if any of the following errors * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and * {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#delete */ delete(key: string, callback: AsyncCallback): void; delete(key: string): Promise; - /** - * Deletes the key-value pair based on a specified key. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @systemapi - * @param predicates Indicates the datasharePredicates. - * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. - */ - delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback); - delete(predicates: dataSharePredicates.DataSharePredicates): Promise; - /** - * Backs up a database in a specified name. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param file Indicates the name that saves the database backup. - */ - backup(file:string, callback: AsyncCallback):void; - backup(file:string): Promise; - - /** - * Restores a database from a specified database file. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param file Indicates the name that saves the database file. - */ - restore(file:string, callback: AsyncCallback):void; - restore(file:string): Promise; - - /** - * Delete a backup files based on a specified name. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param files list Indicates the name that backup file to delete. - */ - deleteBackup(files:Array, callback: AsyncCallback>):void; - deleteBackup(files:Array): Promise>; - - /** - * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in + * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in * {@code KvStoreObserver} will be invoked. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. * @param listener Indicates the observer of data change events in the distributed database. - * @throws Throws this exception if any of the following errors + * @throws Throws this exception if any of the following errors * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ on(event: 'dataChange', type: SubscribeType, listener: Callback): void; /** * Subscribes from the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}. - * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @throws Throws this exception if any of the following errors + * + * @throws Throws this exception if any of the following errors * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ on(event: 'syncComplete', syncCallback: Callback>): void; - + /** * Unsubscribes from the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. - * @throws Throws this exception if any of the following errors + * @throws Throws this exception if any of the following errors * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. - */ - off(event:'dataChange', listener?: Callback): void; - - /** - * UnRegister Synchronizes {@code KvStore} database callback. - * @since 9 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param syncCallback Indicates the callback used to send the synchronization result to caller. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, - * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#off */ - off(event: 'syncComplete', syncCallback?: Callback>): void; + off(event: 'dataChange', listener?: Callback): void; /** * Inserts key-value pairs into the {@code KvStore} database in batches. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param entries Indicates the key-value pairs to be inserted in batches. * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#putBatch */ putBatch(entries: Entry[], callback: AsyncCallback): void; putBatch(entries: Entry[]): Promise; /** * Deletes key-value pairs in batches from the {@code KvStore} database. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param keys Indicates the key-value pairs to be deleted in batches. * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#deleteBatch */ deleteBatch(keys: string[], callback: AsyncCallback): void; deleteBatch(keys: string[]): Promise; /** * Starts a transaction operation in the {@code KvStore} database. - * + * *

After the database transaction is started, you can submit or roll back the operation. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#startTransaction */ startTransaction(callback: AsyncCallback): void; startTransaction(): Promise; /** * Submits a transaction operation in the {@code KvStore} database. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param callback + * + * @param callback * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#commit */ commit(callback: AsyncCallback): void; commit(): Promise; /** * Rolls back a transaction operation in the {@code KvStore} database. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#rollback */ rollback(callback: AsyncCallback): void; rollback(): Promise; /** * Sets whether to enable synchronization. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param enabled Specifies whether to enable synchronization. The value true means to enable * synchronization, and false means the opposite. * @throws Throws this exception if an internal service error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#enableSync */ enableSync(enabled: boolean, callback: AsyncCallback): void; enableSync(enabled: boolean): Promise; /** * Sets synchronization range labels. - * + * *

The labels determine the devices with which data will be synchronized. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param localLabels Indicates the synchronization labels of the local device. * @param remoteSupportLabels Indicates the labels of the devices with which data will be synchronized. * @throws Throws this exception if an internal service error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncRange */ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void; setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; @@ -1338,49 +1415,53 @@ declare namespace distributedData { * The {@code SingleKVStore} database does not support * synchronous transactions, or data search using snapshots. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @version 1 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore */ interface SingleKVStore extends KVStore { /** * Obtains the {@code String} value of a specified key. - * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param key Indicates the key of the boolean value to be queried. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#get */ get(key: string, callback: AsyncCallback): void; get(key: string): Promise; /** * Obtains all key-value pairs that match a specified key prefix. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param keyPrefix Indicates the key prefix to match. * @returns Returns the list of all key-value pairs that match the specified key prefix. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries */ getEntries(keyPrefix: string, callback: AsyncCallback): void; getEntries(keyPrefix: string): Promise; /** * Obtains the list of key-value pairs matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param query Indicates the {@code Query} object. * @returns Returns the list of key-value pairs matching the specified {@code Query} object. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries */ getEntries(query: Query, callback: AsyncCallback): void; getEntries(query: Query): Promise; @@ -1391,78 +1472,68 @@ declare namespace distributedData { * {@code KvStoreResultSet} objects at the same time. If you have created four objects, calling this method will return a * failure. Therefore, you are advised to call the closeResultSet method to close unnecessary {@code KvStoreResultSet} objects * in a timely manner. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param keyPrefix Indicates the key prefix to match. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet */ getResultSet(keyPrefix: string, callback: AsyncCallback): void; getResultSet(keyPrefix: string): Promise; /** * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param query Indicates the {@code Query} object. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet */ getResultSet(query: Query, callback: AsyncCallback): void; getResultSet(query: Query): Promise; - /** - * Obtains the KvStoreResultSet object matching the specified Predicate object. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @systemapi - * @param predicates Indicates the datasharePredicates. - * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. - */ - getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; - getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; - /** * Closes a {@code KvStoreResultSet} object returned by getResultSet. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param resultSet Indicates the {@code KvStoreResultSet} object to close. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#closeResultSet */ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void; closeResultSet(resultSet: KvStoreResultSet): Promise; /** * Obtains the number of results matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @param query Indicates the {@code Query} object. * @returns Returns the number of results matching the specified {@code Query} object. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSize */ getResultSize(query: Query, callback: AsyncCallback): void; getResultSize(query: Query): Promise; /** * void removeDeviceData​({@link String} deviceId) throws {@link KvStoreException} - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#removeDeviceData */ removeDeviceData(deviceId: string, callback: AsyncCallback): void; removeDeviceData(deviceId: string): Promise; @@ -1470,97 +1541,68 @@ declare namespace distributedData { /** * Synchronizes the database to the specified devices with the specified delay allowed. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param deviceIds Indicates the list of devices to which to synchronize the database. - * @param mode Indicates the synchronization mode. The value can be {@code PUSH}, {@code PULL}, or {@code PUSH_PULL}. - * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. - * @throws Throws this exception if any of the following errors - * @permission ohos.permission.DISTRIBUTED_DATASYNC - * occurs: {@code INVALID_ARGUMENT}, - * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. - */ - sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void - - /** - * Synchronizes the database to the specified devices with the specified delay allowed. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param deviceIds Indicates the list of devices to which to synchronize the database. * @param mode Indicates the synchronization mode. The value can be {@code PUSH}, {@code PULL}, or {@code PUSH_PULL}. * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. - * @param query Indicates the {@code Query} object. * @throws Throws this exception if any of the following errors * @permission ohos.permission.DISTRIBUTED_DATASYNC - * occurs: {@code INVALID_ARGUMENT}, + * occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. - */ - sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; - - /** - * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in - * {@code KvStoreObserver} will be invoked. - * - * @since 9 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. - * @param listener Indicates the observer of data change events in the distributed database. - * @throws Throws this exception if no {@code SingleKvStore} database is available. - * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#sync */ - on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; /** - * Register Synchronizes SingleKvStore databases callback. + * Register Synchronizes SingleKvStore databases callback. *

Sync result is returned through asynchronous callback. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param syncCallback Indicates the callback used to send the synchronization result to the caller. * @throws Throws this exception if no {@code SingleKvStore} database is available. - */ - on(event: 'syncComplete', syncCallback: Callback>): void; - - /** - * Unsubscribes from the SingleKvStore database based on the specified subscribeType and {@code KvStoreObserver}. - * @since 9 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, - * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ - off(event:'dataChange', listener?: Callback): void; + on(event: 'syncComplete', syncCallback: Callback>): void; /** * UnRegister Synchronizes SingleKvStore databases callback. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @throws Throws this exception if no {@code SingleKvStore} database is available. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#off */ off(event: 'syncComplete', syncCallback?: Callback>): void; - - + /** * Sets the default delay allowed for database synchronization - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param defaultAllowedDelayMs Indicates the default delay allowed for the database synchronization, in milliseconds. * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncParam */ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback): void; setSyncParam(defaultAllowedDelayMs: number): Promise; /** * Get the security level of the database. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @returns SecurityLevel {@code SecurityLevel} the security level of the database. * @throws Throws this exception if any of the following errors occurs:{@code SERVER_UNAVAILABLE}, * {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getSecurityLevel */ getSecurityLevel(callback: AsyncCallback): void; getSecurityLevel(): Promise; @@ -1568,177 +1610,168 @@ declare namespace distributedData { /** * Manages distributed data by device in a distributed system. - * + * *

To create a {@code DeviceKVStore} database, you can use the {@link data.distributed.common.KVManager.getKvStore(Options, String)} * method with {@code KvStoreType} set to {@code DEVICE_COLLABORATION} for the input parameter Options. This database manages distributed * data by device, and cannot modify data synchronized from remote devices. When an application writes a key-value pair entry * into the database, the system automatically adds the ID of the device running the application to the key. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore */ interface DeviceKVStore extends KVStore { /** * Obtains the {@code String} value matching a specified device ID and key. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore * @param deviceId Indicates the device to be queried. * @param key Indicates the key of the value to be queried. * @return Returns the value matching the given criteria. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#get */ get(deviceId: string, key: string, callback: AsyncCallback): void; get(deviceId: string, key: string): Promise; /** * Obtains all key-value pairs matching a specified device ID and key prefix. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Identifies the device whose data is to be queried. * @param keyPrefix Indicates the key prefix to match. * @returns Returns the list of all key-value pairs meeting the given criteria. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; getEntries(deviceId: string, keyPrefix: string): Promise; /** * Obtains the list of key-value pairs matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param query Indicates the {@code Query} object. * @returns Returns the list of key-value pairs matching the specified {@code Query} object. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ getEntries(query: Query, callback: AsyncCallback): void; getEntries(query: Query): Promise; /** * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Indicates the ID of the device to which the key-value pairs belong. * @param query Indicates the {@code Query} object. * @returns Returns the list of key-value pairs matching the specified {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ getEntries(deviceId: string, query: Query, callback: AsyncCallback): void; getEntries(deviceId: string, query: Query): Promise; /** * Obtains the {@code KvStoreResultSet} object matching the specified device ID and key prefix. - * + * *

The {@code KvStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code KvStore} * instance can have a maximum of four {@code KvStoreResultSet} objects at the same time. If you have created four objects, * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary * {@code KvStoreResultSet} objects in a timely manner. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Identifies the device whose data is to be queried. * @param keyPrefix Indicates the key prefix to match. * @returns Returns the {@code KvStoreResultSet} objects. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; getResultSet(deviceId: string, keyPrefix: string): Promise; /** * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param query Indicates the {@code Query} object. * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ getResultSet(query: Query, callback: AsyncCallback): void; getResultSet(query: Query): Promise; /** * Obtains the {@code KvStoreResultSet} object matching a specified device ID and {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Indicates the ID of the device to which the {@code KvStoreResultSet} object belongs. * @param query Indicates the {@code Query} object. * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ getResultSet(deviceId: string, query: Query, callback: AsyncCallback): void; getResultSet(deviceId: string, query: Query): Promise; - /** - * Obtains the KvStoreResultSet object matching the specified Predicate object. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param predicates Indicates the datasharePredicates. - * @systemapi - * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. - */ - getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; - getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; - - /** - * Obtains the KvStoreResultSet object matching a specified Device ID and Predicate object. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @systemapi - * @param predicates Indicates the key. - * @param deviceId Indicates the ID of the device to which the results belong. - * Spaces before and after the key will be cleared. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and - * {@code DB_ERROR}. - */ - getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; - getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise; - /** * Closes a {@code KvStoreResultSet} object returned by getResultSet. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param resultSet Indicates the {@code KvStoreResultSet} object to close. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#closeResultSet */ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback): void; closeResultSet(resultSet: KvStoreResultSet): Promise; /** * Obtains the number of results matching the specified {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param query Indicates the {@code Query} object. * @returns Returns the number of results matching the specified {@code Query} object. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize */ getResultSize(query: Query, callback: AsyncCallback): void; getResultSize(query: Query): Promise; /** * Obtains the number of results matching a specified device ID and {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Indicates the ID of the device to which the results belong. * @param query Indicates the {@code Query} object. * @returns Returns the number of results matching the specified {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize */ getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void; getResultSize(deviceId: string, query: Query): Promise; @@ -1747,107 +1780,77 @@ declare namespace distributedData { * Removes data of a specified device from the current database. This method is used to remove only the data * synchronized from remote devices. This operation does not synchronize data to other databases or affect * subsequent data synchronization. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * * @param deviceId Identifies the device whose data is to be removed. The value cannot be the current device ID. * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#removeDeviceData */ removeDeviceData(deviceId: string, callback: AsyncCallback): void; removeDeviceData(deviceId: string): Promise; - - /** - * Synchronizes {@code DeviceKVStore} databases. - * - *

This method returns immediately and sync result will be returned through asynchronous callback. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param deviceIds Indicates the list of IDs of devices whose - * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. - * {@code DeviceKVStore} databases are to be synchronized. - * @param mode Indicates the synchronization mode, {@code PUSH}, {@code PULL}, or - * {@code PUSH_PULL}. - * @permission ohos.permission.DISTRIBUTED_DATASYNC - * @throws Throws this exception if no DeviceKVStore database is available. - */ - sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; /** * Synchronizes {@code DeviceKVStore} databases. * *

This method returns immediately and sync result will be returned through asynchronous callback. - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param deviceIds Indicates the list of IDs of devices whose * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds. * {@code DeviceKVStore} databases are to be synchronized. - * @param query Indicates the {@code Query} object. * @param mode Indicates the synchronization mode, {@code PUSH}, {@code PULL}, or * {@code PUSH_PULL}. - * @permission ohos.permission.DISTRIBUTED_DATASYNC * @throws Throws this exception if no DeviceKVStore database is available. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#sync */ - sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; /** * Register Synchronizes DeviceKVStore databases callback. - * + * *

Sync result is returned through asynchronous callback. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param syncCallback Indicates the callback used to send the synchronization result to the caller. * @throws Throws this exception if no DeviceKVStore database is available. - */ - on(event: 'syncComplete', syncCallback: Callback>): void; - - /** - * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in - * {@code KvStoreObserver} will be invoked. - * - * @since 9 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param type Indicates the subscription type, which is defined in {@code SubscribeType}. - * @param listener Indicates the observer of data change events in the distributed database. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, - * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#on */ - on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + on(event: 'syncComplete', syncCallback: Callback>): void; /** - * Unsubscribes from the DeviceKVStore database based on the specified subscribeType and {@code KvStoreObserver}. + * UnRegister Synchronizes DeviceKVStore databases callback. * - * @since 9 + * @throws Throws this exception if no DeviceKVStore database is available. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}. - * @throws Throws this exception if any of the following errors - * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, - * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}. - */ - off(event:'dataChange', listener?: Callback): void; - - /** - * UnRegister Synchronizes DeviceKVStore databases callback. * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @throws Throws this exception if no DeviceKVStore database is available. + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#off */ off(event: 'syncComplete', syncCallback?: Callback>): void; } - + /** * Creates a {@link KVManager} instance based on the configuration information. * *

You must pass {@link KVManagerConfig} to provide configuration information * for creating the {@link KVManager} instance. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param config Indicates the {@link KVStore} configuration information, * including the user information and package name. * @return Returns the {@code KVManager} instance. * @throws Throws exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore#createKVManager */ function createKVManager(config: KVManagerConfig, callback: AsyncCallback): void; function createKVManager(config: KVManagerConfig): Promise; @@ -1855,23 +1858,26 @@ declare namespace distributedData { /** * Provides interfaces to manage a {@code KVStore} database, including obtaining, closing, and deleting the {@code KVStore}. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @version 1 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager */ interface KVManager { /** * Creates and obtains a {@code KVStore} database by specifying {@code Options} and {@code storeId}. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @param options Indicates the options used for creating and obtaining the {@code KVStore} database, * including {@code isCreateIfMissing}, {@code isEncrypt}, and {@code KVStoreType}. * @param storeId Identifies the {@code KVStore} database. * The value of this parameter must be unique for the same application, * and different applications can share the same value. * @return Returns a {@code KVStore}, or {@code SingleKVStore}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#getKVStore */ getKVStore(storeId: string, options: Options): Promise; getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; @@ -1886,14 +1892,16 @@ declare namespace distributedData { * method, release the resources created for the database, for example, {@code KvStoreResultSet} for {@code SingleKvStore}, * otherwise closing the database will fail. If you are attempting to close a database that is already closed, an error * will be returned. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param kvStore Indicates the {@code KvStore} database to close. * @throws Throws this exception if any of the following errors * occurs:{@code INVALID_ARGUMENT}, {@code ERVER_UNAVAILABLE}, * {@code STORE_NOT_OPEN}, {@code STORE_NOT_FOUND}, {@code DB_ERROR}, * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#closeKVStore */ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback): void; closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise; @@ -1905,13 +1913,16 @@ declare namespace distributedData { * *

You can use this method to delete a {@code KvStore} database not in use. After the database is deleted, all its data will be * lost. - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * * @param storeId Identifies the {@code KvStore} database to delete. * @throws Throws this exception if any of the following errors * occurs: {@code INVALID_ARGUMENT}, * {@code SERVER_UNAVAILABLE}, {@code STORE_NOT_FOUND}, * {@code DB_ERROR}, {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#deleteKVStore */ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void; deleteKVStore(appId: string, storeId: string): Promise; @@ -1920,12 +1931,14 @@ declare namespace distributedData { * Obtains the storeId of all {@code KvStore} databases that are created by using the {@code getKvStore} method and not deleted by * calling the {@code deleteKvStore} method. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @returns Returns the storeId of all created {@code KvStore} databases. + * @returns Returns the storeId of all created {@code KvStore} databases. * @throws Throws this exception if any of the following errors * occurs: {@code SERVER_UNAVAILABLE}, {@code DB_ERROR}, * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#getAllKVStoreId */ getAllKVStoreId(appId: string, callback: AsyncCallback): void; getAllKVStoreId(appId: string): Promise; @@ -1933,20 +1946,24 @@ declare namespace distributedData { /** * register DeviceChangeCallback to get notification when device's status changed * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore * @param deathCallback device change callback {@code DeviceChangeCallback} * @throws exception maybe occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#on */ on(event: 'distributedDataServiceDie', deathCallback: Callback): void; /** * unRegister DeviceChangeCallback and can not receive notification * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore * @param deathCallback device change callback {@code DeviceChangeCallback} which has been registered. * @throws exception maybe occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#off */ off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; } diff --git a/api/@ohos.data.distributedKVStore.d.ts b/api/@ohos.data.distributedKVStore.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc55042a399f041d979665986143ff47ed056fa9 --- /dev/null +++ b/api/@ohos.data.distributedKVStore.d.ts @@ -0,0 +1,2147 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback, Callback } from './basic'; +import { ValuesBucket } from './@ohos.data.ValuesBucket'; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; +import Context from './application/Context'; + +/** + * Provider interfaces to create a {@link KVManager} istances. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ +declare namespace distributedKVStore { + /** + * Provides configuration information to create a {@link KVManager} instance, + * which includes the caller's package name and ability or hap context. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface KVManagerConfig { + /** + * Indicates the bundleName + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + bundleName: string; + + /** + * Indicates the ability or hap context + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @Note: if swap the area, you should close all the KV store and use the new Context to create the KVManager + * @since 9 + */ + context: Context; + } + + /** + * KVStore constants + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + namespace Constants { + /** + * Max key length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_KEY_LENGTH = 1024; + + /** + * Max value length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_VALUE_LENGTH = 4194303; + + /** + * Max device coordinate key length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_KEY_LENGTH_DEVICE = 896; + + /** + * Max store id length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_STORE_ID_LENGTH = 128; + + /** + * Max query length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_QUERY_LENGTH = 512000; + + /** + * Max batch operation size. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_BATCH_SIZE = 128; + } + + /** + * Indicates the {@code ValueType}. + * + *

{@code ValueType} is obtained based on the value. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum ValueType { + /** + * Indicates that the value type is string. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + STRING, + + /** + * Indicates that the value type is int. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + INTEGER, + + /** + * Indicates that the value type is float. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + FLOAT, + + /** + * Indicates that the value type is byte array. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + * */ + BYTE_ARRAY, + + /** + * Indicates that the value type is boolean. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + * */ + BOOLEAN, + + /** + * Indicates that the value type is double. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + DOUBLE, + } + + /** + * Obtains {@code Value} objects stored in a {@link SingleKVStore} or {@link DeviceKVStore} database. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Value { + /** + * Indicates the value type + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @see ValueType + * @since 9 + */ + type: ValueType; + /** + * Indicates the value + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + value: Uint8Array | string | number | boolean; + } + + /** + * Provides key-value pairs stored in the distributedKVStore. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Entry { + /** + * Indicates the key + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + key: string; + /** + * Indicates the value + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + value: Value; + } + + /** + * Receive notifications of all data changes, including data insertion, update, and deletion. + * + *

If you have subscribed to {@code SingleKVStore} or {@code DeviceKVStore}, you will receive + * data change notifications and obtain the changed data from the parameters in callback methods + * upon data insertion, update or deletion. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface ChangeNotification { + /** + * Indicates data insertion records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + insertEntries: Entry[]; + /** + * Indicates data update records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + updateEntries: Entry[]; + /** + * Indicates data deletion records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteEntries: Entry[]; + /** + * Indicates the device id which brings the data change. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deviceId: string; + } + + /** + * Indicates the database synchronization mode. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SyncMode { + /** + * Indicates that data is only pulled from the remote end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PULL_ONLY, + /** + * Indicates that data is only pushed from the local end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PUSH_ONLY, + /** + * Indicates that data is pushed from the local end, and then pulled from the remote end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PUSH_PULL, + } + + /** + * Describes the subscription type. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SubscribeType { + /** + * Subscription to local data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_LOCAL, + + /** + * Subscription to remote data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_REMOTE, + + /** + * Subscription to both local and remote data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_ALL, + } + + /** + * Describes the KVStore type. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum KVStoreType { + /** + * Device-collaborated database, as specified by {@code DeviceKVStore} + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + DEVICE_COLLABORATION, + + /** + * Single-version database, as specified by {@code SingleKVStore} + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SINGLE_VERSION, + } + + /** + * Describes the KVStore security level. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SecurityLevel { + /** + * S1: means the db is in the low security level + * There are some low impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S1, + + /** + * S2: means the db is in the middle security level + * There are some major impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S2, + + /** + * S3: means the db is in the high security level + * There are some severity impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S3, + + /** + * S4: means the db is in the critical security level + * There are some critical impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S4, + } + + /** + * Provides configuration options to create a {@code SingleKVStore} or {@code DeviceKVStore}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Options { + /** + * Indicates whether to create a database when the database file does not exist + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + createIfMissing?: boolean; + /** + * Indicates whether database files to be encrypted + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + encrypt?: boolean; + /** + * Indicates whether to back up database files + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup?: boolean; + /** + * Indicates whether database files are automatically synchronized + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + autoSync?: boolean; + /** + * Indicates the database type + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + kvStoreType?: KVStoreType; + /** + * Indicates the database security level + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + securityLevel: SecurityLevel; + /** + * Indicates the database schema + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + schema?: Schema; + } + + /** + * Represents the database schema. + * + * You can set the schema object in options when create or open the database. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + class Schema { + /** + * A constructor used to create a Schema instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + constructor() + /** + * Indicates the root json object. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + root: FieldNode; + /** + * Indicates the string array of json. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + indexes: Array; + /** + * Indicates the mode of schema. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + mode: number; + /** + * Indicates the skip size of schema. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + skip: number; + } + + /** + * Represents a node of a {@link Schema} instance. + * + *

With a {@link Schema} instance, you can define the value fields which stored in the database. + * + *

A FieldNode of the {@link Schema} instance is either a leaf or a non-leaf node. + * + *

The leaf node must have a value; the non-leaf node must have a child {@code FieldNode}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + class FieldNode { + /** + * A constructor used to create a FieldNode instance with the specified field. + * name Indicates the field node name. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + constructor(name: string) + /** + * Adds a child node to this {@code FieldNode}. + * + *

Add a child node to makes this node a non-leaf node and field value will be ignored if it has a child node. + * + * @param {FieldNode} child - The field node to append. + * @returns Returns true if the child node is successfully added to this {@code FieldNode} and false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + appendChild(child: FieldNode): boolean; + /** + * Indicates the default value of field node. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + default: string; + /** + * Indicates the nullable of database field. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + nullable: boolean; + /** + * Indicates the type of value. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + type: number; + } + + /** + * Provides methods to operate the result set of the {@code SingleKVStore} or {@code DeviceKVStore} database. + * + *

The result set is created by using the {@code getResultSet} method in the {@code SingleKVStore} or + * {@code DeviceKVStore} class. This interface also provides methods to move the data read + * position in the result set. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface KVStoreResultSet { + /** + * Obtains the number of lines in a result set. + * + * @returns Returns the number of lines. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getCount(): number; + /** + * Obtains the current read position in a result set. + * + * @returns Returns the current read position. The read position starts with 0. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getPosition(): number; + /** + * Moves the read position to the first line. + * + *

If the result set is empty, false is returned. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToFirst(): boolean; + /** + * Moves the read position to the last line. + * + *

If the result set is empty, false is returned. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToLast(): boolean; + /** + * Moves the read position to the next line. + * + *

If the result set is empty or the data in the last line is being read, false is returned. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToNext(): boolean; + /** + * Moves the read position to the previous line. + * + *

If the result set is empty or the data in the first line is being read, false is returned. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToPrevious(): boolean; + /** + * Moves the read position by a relative offset to the current position. + * + * @param {number} offset - Indicates the relative offset to the current position. Anegative offset indicates moving + * backwards, and a positive offset indicates moving forewards. Forexample, if the current position is entry 1 and + * thisoffset is 2, the destination position will be entry 3; ifthe current position is entry 3 and this offset is -2, + * the destination position will be entry 1. The valid final position after moving forwards starts with 0. If the + * final position is invalid, false will be returned. + * @returns Returns true if the operation succeeds; return false otherwise. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + move(offset: number): boolean; + /** + * Moves the read position from 0 to an absolute position. + * + * @param {number} position - Indicates the absolute position. + * @returns Returns true if the operation succeeds; return false otherwise. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToPosition(position: number): boolean; + /** + * Checks whether the read position is the first line. + * + * @returns Returns true if the read position is the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isFirst(): boolean; + /** + * Checks whether the read position is the last line. + * + * @returns Returns true if the read position is the last line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isLast(): boolean; + /** + * Checks whether the read position is before the last line. + * + * @returns Returns true if the read position is before the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isBeforeFirst(): boolean; + /** + * Checks whether the read position is after the last line. + * + * @returns Returns true if the read position is after the last line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isAfterLast(): boolean; + /** + * Obtains a key-value pair. + * + * @returns Returns a key-value pair. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntry(): Entry; + } + + /** + * Represents a database query using predicates. + * + *

This class provides a constructor used to create a {@code Query} instance, which is used to query data + * matching specified conditions in the database. + * + *

This class also provides methods to add predicates to the {@code Query} instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + class Query { + /** + * A constructor used to create a Query instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + constructor() + /** + * Resets this {@code Query} object. + * + * @returns Returns the reset {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + reset(): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + equalTo(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not equal to the specified int value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + notEqualTo(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the + * specified int value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + greaterThan(field: string, value: number | string | boolean): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is less than the specified int value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + lessThan(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or + * equal to the specified int value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + greaterThanOrEqualTo(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is less than or equal to the + * specified int value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + lessThanOrEqualTo(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is null. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isNull(field: string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified int value list. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number[]} valueList - Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + inNumber(field: string, valueList: number[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified string value list. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string[]} valueList - Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + inString(field: string, valueList: string[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified int value list. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number[]} valueList - Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + notInNumber(field: string, valueList: number[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified string value list. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string[]} valueList - Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + notInString(field: string, valueList: string[]): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is similar to the specified string value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string} value - Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + like(field: string, value: string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is not similar to the specified string value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string} value - Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + unlike(field: string, value: string): Query; + /** + * Constructs a {@code Query} object with the and condition. + * + *

Multiple predicates should be connected using the and or or condition. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + and(): Query; + /** + * Constructs a {@code Query} object with the or condition. + * + *

Multiple predicates should be connected using the and or or condition. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + or(): Query; + /** + * Constructs a {@code Query} object to sort the query results in ascending order. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + orderByAsc(field: string): Query; + /** + * Constructs a {@code Query} object to sort the query results in descending order. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + orderByDesc(field: string): Query; + /** + * Constructs a {@code Query} object to specify the number of results and the start position. + * + * @param {number} total - Indicates the number of results. + * @param {number} offset - Indicates the start position. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + limit(total: number, offset: number): Query; + /** + * Creates a {@code Query} condition with a specified field that is not null. + * + * @param {string} field - Indicates the specified field. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isNotNull(field: string): Query; + /** + * Creates a query condition group with a left bracket. + * + *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a + * whole to combine with other query conditions. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + beginGroup(): Query; + /** + * Creates a query condition group with a right bracket. + * + *

Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a + * whole to combine with other query conditions. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + endGroup(): Query; + /** + * Creates a query condition with a specified key prefix. + * + * @param {string} prefix - Indicates the specified key prefix. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + prefixKey(prefix: string): Query; + /** + * Sets a specified index that will be preferentially used for query. + * + * @param {string} index - Indicates the index to set. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSuggestIndex(index: string): Query; + /** + * Add device ID key prefix.Used by {@code DeviceKVStore}. + * + * @param {string} deviceId - Specify device id to query from. + * @return Returns the {@code Query} object with device ID prefix added. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deviceId(deviceId:string):Query; + /** + * Get a String that repreaents this {@code Query}. + * + *

The String would be parsed to DB query format. + * The String length should be no longer than 500kb. + * + * @return String representing this {@code Query}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSqlLike():string; + } + + /** + * Provides methods related to single-version distributed databases. + * + *

To create a {@code SingleKVStore} database, + * you can use the {@link data.distributed.common.KVManager#getKVStore​(Options, String)} method + * with {@code KVStoreType} set to {@code SINGLE_VERSION} for the input parameter {@code Options}. + * This database synchronizes data to other databases in time sequence. + * The {@code SingleKVStore} database does not support + * synchronous transactions, or data search using snapshots. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface SingleKVStore { + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + * + *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {Uint8Array|string|number|boolean} value - Indicates the value to be inserted. + * @param {AsyncCallback} callback - the callback of put. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; + + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + * + *

If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {Uint8Array|string|number|boolean} value - Indicates the value to be inserted. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + put(key: string, value: Uint8Array | string | number | boolean): Promise; + + /** + * Inserts key-value pairs into the {@code SingleKVStore} database in batches. + * + * @param {Entry[]} entries - Indicates the key-value pairs to be inserted in batches. + * @param {AsyncCallback} callback - the callback of putBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + putBatch(entries: Entry[], callback: AsyncCallback): void; + + /** + * Inserts key-value pairs into the {@code SingleKVStore} database in batches. + * + * @param {Entry[]} entries - Indicates the key-value pairs to be inserted in batches. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + putBatch(entries: Entry[]): Promise; + + /** + * Writes values of ValuesBucket type into the {@code SingleKVStore} database. + * + * @param {Array} value - Indicates the ValuesBucket array to be inserted. + * @param {AsyncCallback} callback - the callback of putBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @systemapi + * @since 9 + */ + putBatch(value: Array, callback: AsyncCallback): void; + + /** + * Writes values of ValuesBucket type into the {@code SingleKVStore} database. + * + * @param {Array} value - Indicates the ValuesBucket array to be inserted. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @systemapi + * @since 9 + */ + putBatch(value: Array): Promise; + + /** + * Deletes the key-value pair based on a specified key. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {AsyncCallback} callback - the callback of delete. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + delete(key: string, callback: AsyncCallback): void; + + /** + * Deletes the key-value pair based on a specified key. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + delete(key: string): Promise; + + /** + * Deletes the key-value pairs based on the dataSharePredicates. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @param {AsyncCallback} callback - the callback of delete. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback); + + /** + * Deletes the key-value pairs based on the dataSharePredicates. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + delete(predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Deletes key-value pairs in batches from the {@code SingleKVStore} database. + * + * @param {string[]} keys - Indicates the key-value pairs to be deleted in batches. + * @param {AsyncCallback} callback - the callback of deleteBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBatch(keys: string[], callback: AsyncCallback): void; + + /** + * Deletes key-value pairs in batches from the {@code SingleKVStore} database. + * + * @param {string[]} keys - Indicates the key-value pairs to be deleted in batches. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBatch(keys: string[]): Promise; + + /** + * Removes data of the specified device from current database. This method is used to remove only the data + * synchronized from remote devices. This operation does not synchronize data to other databases or affect + * subsequent data synchronization. + * + * @param {string} deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. + * @param {AsyncCallback} callback - the callback of removeDeviceData. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + removeDeviceData(deviceId: string, callback: AsyncCallback): void; + + /** + * Removes data of the specified device from current database. This method is used to remove only the data + * synchronized from remote devices. This operation does not synchronize data to other databases or affect + * subsequent data synchronization. + * + * @param {string} deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + removeDeviceData(deviceId: string): Promise; + + /** + * Obtains the value of a specified key. + * + * @param {string} key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @param {AsyncCallback} callback - + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + get(key: string, callback: AsyncCallback): void; + + /** + * Obtains the value of a specified key. + * + * @param {string} key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @returns {Promise} + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + get(key: string): Promise; + + /** + * Obtains all key-value pairs that match a specified key prefix. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + \* @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * that match the specified key prefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains all key-value pairs that match a specified key prefix. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {Entry[]}: the list of all key-value pairs that match the + * specified key prefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(keyPrefix: string): Promise; + + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {Entry[]}: the list of all key-value pairs matching the + * specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(query: Query): Promise; + + /** + * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} + * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created + * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet + * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} + * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created + * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet + * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(keyPrefix: string): Promise; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(query: Query): Promise; + + /** + * Obtains the KVStoreResultSet object matching the specified predicate object. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the datasharePredicates. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Obtains the KVStoreResultSet object matching the specified predicate object. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the datasharePredicates. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Closes a {@code KVStoreResultSet} object returned by getResultSet method. + * + * @param {KVStoreResultSet} resultSet - Indicates the {@code KVStoreResultSet} object to close. + * @param {AsyncCallback} callback - the callback of closeResultSet. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeResultSet(resultSet: KVStoreResultSet, callback: AsyncCallback): void; + + /** + * Closes a {@code KVStoreResultSet} object returned by getResultSet method. + * + * @param {KVStoreResultSet} resultSet - Indicates the {@code KVStoreResultSet} object to close. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeResultSet(resultSet: KVStoreResultSet): Promise; + + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {number}: the number of results matching the + * specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSize(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {number}: the number of results matching the specified + * {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSize(query: Query): Promise; + + /** + * Backs up a database in the specified filename. + * + * @param {string} file - Indicates the database backup filename. + * @param {AsyncCallback} callback - the callback of backup. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup(file:string, callback: AsyncCallback):void; + + /** + * Backs up a database in the specified filename. + * + * @param {string} file - Indicates the database backup filename. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup(file:string): Promise; + + /** + * Restores a database from a specified database file. + * + * @param {string} file - Indicates the database backup filename. + * @param {AsyncCallback} callback - the callback of restore. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + restore(file:string, callback: AsyncCallback):void; + + /** + * Restores a database from a specified database file. + * + * @param {string} file - Indicates the database backup filename. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + restore(file:string): Promise; + + /** + * Delete database backup files based on the specified filenames. + * + * @param {Array} files - Indicates the backup filenames to be deleted. + * @param {AsyncCallback>} callback - {Array<[string, number]>}: + * the list of backup file and it's corresponding delete result which 0 means delete success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBackup(files:Array, callback: AsyncCallback>):void; + + /** + * Delete database backup files based on the specified filenames. + * + * @param {Array} files - Indicates the backup filenames to be deleted. + * @returns {Promise>} {Array<[string, number]>}: the list of backup + * file and it's corresponding delete result which 0 means delete success and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBackup(files:Array): Promise>; + + /** + * Starts a transaction operation in the {@code SingleKVStore} database. + * + *

After the database transaction is started, you can submit or roll back the operation. + * + * @param {AsyncCallback} callback - the callback of startTransaction. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + startTransaction(callback: AsyncCallback): void; + + /** + * Starts a transaction operation in the {@code SingleKVStore} database. + * + *

After the database transaction is started, you can submit or roll back the operation. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + startTransaction(): Promise; + + /** + * Submits a transaction operation in the {@code SingleKVStore} database. + * + * @param {AsyncCallback} callback - the callback of commit. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + commit(callback: AsyncCallback): void; + + /** + * Submits a transaction operation in the {@code SingleKVStore} database. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + commit(): Promise; + + /** + * Rolls back a transaction operation in the {@code SingleKVStore} database. + * + * @param {AsyncCallback} callback - the callback of rollback. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + rollback(callback: AsyncCallback): void; + + /** + * Rolls back a transaction operation in the {@code SingleKVStore} database. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + rollback(): Promise; + + /** + * Sets whether to enable synchronization. + * + * @param {boolean} enabled - Specifies whether to enable synchronization. The value true + * means to enable synchronization, and false means the opposite. + * @param {AsyncCallback} callback - the callback of enableSync. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enableSync(enabled: boolean, callback: AsyncCallback): void; + + /** + * Sets whether to enable synchronization. + * + * @param {boolean} enabled - Specifies whether to enable synchronization. The value true + * means to enable synchronization, and false means the opposite. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enableSync(enabled: boolean): Promise; + + /** + * Sets synchronization range labels. + * + *

The labels determine the devices with which data will be synchronized. + * + * @param {string[]} localLabels - Indicates the synchronization labels of the local device. + * @param {string[]} remoteSupportLabels - Indicates the labels of the devices with which + * data will be synchronized. + * @param {AsyncCallback} callback - the callback of setSyncRange. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void; + + /** + * Sets synchronization range labels. + * + *

The labels determine the devices with which data will be synchronized. + * + * @param {string[]} localLabels - Indicates the synchronization labels of the local device. + * @param {string[]} remoteSupportLabels - Indicates the labels of the devices with which + * data will be synchronized. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; + + /** + * Sets the default delay allowed for database synchronization + * + * @param {number} defaultAllowedDelayMs - Indicates the default delay allowed for the + * database synchronization, in milliseconds. + * @param {AsyncCallback} callback - the callback of setSyncParam. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback): void; + + /** + * Sets the default delay allowed for database synchronization + * + * @param {number} defaultAllowedDelayMs - Indicates the default delay allowed for the + * database synchronization, in milliseconds. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncParam(defaultAllowedDelayMs: number): Promise; + + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string[]} deviceIds - Indicates the list of devices to which to synchronize the database. + * @param {SyncMode} mode - Indicates the synchronization mode. The value can be {@code PUSH}, + * {@code PULL}, or {@code PUSH_PULL}. + * @param {number} delayMs - Indicates the delay allowed for the synchronization, in milliseconds. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the database not exist when sync data. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void + + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string[]} deviceIds - Indicates the list of devices to which to synchronize the database. + * @param {Query} query - Indicates the {@code Query} object. + * @param {SyncMode} mode - Indicates the synchronization mode. The value can be {@code PUSH}, + * {@code PULL}, or {@code PUSH_PULL}. + * @param {number} delayMs - Indicates the delay allowed for the synchronization, in milliseconds. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the database not exist when sync data. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + + /** + * Register a callback to the database and when data in the distributed database has changed, + * the callback will be invoked. + * + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param {Callback} listener - {ChangeNotification}: the {@code ChangeNotification} + * object indicates the data change events in the distributed database. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100001 - if the database has been subscribed over the max subscription time limit. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + + /** + * Register a databases synchronization callback to the database. + *

Sync result is returned through asynchronous callback. + * + * @param {Callback>} syncCallback - {Array<[string, number]>}: the + * deviceId and it's corresponding synchronization result which 0 means synchronization success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + on(event: 'syncComplete', syncCallback: Callback>): void; + + /** + * Unsubscribe from the SingleKVStore database based on the specified subscribeType and listener. + * + * @param {Callback} listener - {ChangeNotification}: the {@code ChangeNotification} + * object indicates the data change events in the distributed database. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + off(event:'dataChange', listener?: Callback): void; + + /** + * Unregister the database synchronization callback. + * + * @param {Callback>} syncCallback - {Array<[string, number]>}: the + * deviceId and it's corresponding synchronization result which 0 means synchronization success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + off(event: 'syncComplete', syncCallback?: Callback>): void; + + /** + * Get the security level of the database. + * + * @param {AsyncCallback} callback - {SecurityLevel}: the {@code SecurityLevel} + * object indicates the security level of the database. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSecurityLevel(callback: AsyncCallback): void; + + /** + * Get the security level of the database. + * + * @returns {Promise} {SecurityLevel}: the {@code SecurityLevel} object indicates + * the security level of the database. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSecurityLevel(): Promise; + } + + /** + * Provides methods related to device-collaboration distributed databases. + * + *

To create a {@code DeviceKVStore} database, you can use the {@link data.distributed.common.KVManager.getKVStore(Options, String)} + * method with {@code KVStoreType} set to {@code DEVICE_COLLABORATION} for the input parameter Options. This database manages distributed + * data by device, and cannot modify data synchronized from remote devices. When an application writes a key-value pair entry + * into the database, the system automatically adds the ID of the device running the application to the key. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + interface DeviceKVStore extends SingleKVStore { + /** + * Obtains the {@code String} value matching a specified device ID and key. + * + * @param {string} deviceId - Indicates the device to be queried. + * @param {string} key - Indicates the key of the value to be queried. + * @param {AsyncCallback} callback - + * {boolean|string|number|Uint8Array}: the returned value specified by the deviceId and key. + * @return Returns the value matching the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + get(deviceId: string, key: string, callback: AsyncCallback): void; + + /** + * Obtains the {@code String} value matching a specified device ID and key. + * + * @param {string} deviceId - Indicates the device to be queried. + * @param {string} key - Indicates the key of the value to be queried. + * @returns {Promise} + * {Uint8Array|string|boolean|number}: the returned value specified by the deviceId and key. + * @return Returns the value matching the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + get(deviceId: string, key: string): Promise; + + /** + * Obtains all key-value pairs matching a specified device ID and key prefix. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * that match the specified deviceId and key prefix. + * @returns Returns the list of all key-value pairs meeting the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains all key-value pairs matching a specified device ID and key prefix. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {Entry[]}: the list of all key-value pairs that match the + * specified deviceId and key prefix. + * @returns Returns the list of all key-value pairs meeting the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, keyPrefix: string): Promise; + + /** + * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the key-value pairs belong. + * @param {string} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the key-value pairs belong. + * @param {string} query - Indicates the {@code Query} object. + * @returns {Promise} {Entry[]}: the list of all key-value pairs matching the + * specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, query: Query): Promise; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. + * + *

The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, + * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary + * {@code KVStoreResultSet} objects in a timely manner. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. + * + *

The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, + * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary + * {@code KVStoreResultSet} objects in a timely manner. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, keyPrefix: string): Promise; + + /** + * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, query: Query): Promise; + + /** + * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. + * + * @param deviceId Indicates the ID of the device to which the results belong. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. + * + * @param deviceId Indicates the ID of the device to which the results belong. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Obtains the number of results matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the results belong. + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {number}: the number of results matching the + * specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the number of results matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the results belong. + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {number}: the number of results matching the specified + * deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSize(deviceId: string, query: Query): Promise; + } + + /** + * Creates a {@link KVManager} instance based on the configuration information. + * + *

You must pass {@link KVManagerConfig} to provide configuration information + * to create a {@link KVManager} instance. + * + * @param {KVManagerConfig} config - Indicates the KVStore configuration information, + * including the package name and context. + * @param {AsyncCallback} callback - {KVManager}: the {@code KVManager} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + function createKVManager(config: KVManagerConfig, callback: AsyncCallback): void; + + /** + * Creates a {@link KVManager} instance based on the configuration information. + * + *

You must pass {@link KVManagerConfig} to provide configuration information + * to create a {@link KVManager} instance. + * + * @param {KVManagerConfig} config - Indicates the KVStore configuration information, + * including the package name and context. + * @returns {Promise} {KVManager}: the {@code KVManager} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + function createKVManager(config: KVManagerConfig): Promise; + + /** + * Provides interfaces to manage a {@code SingleKVStore} database, including obtaining, closing, and deleting the {@code SingleKVStore}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface KVManager { + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param {string} storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. + * @param {Options} options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @param {AsyncCallback} callback - {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100002 - if open existed database with changed options. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; + + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param {string} storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. + * @param {Options} options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @returns {Promise} {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100002 - if open existed database with changed options. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getKVStore(storeId: string, options: Options): Promise; + + /** + * Closes the KVStore database. + * + *

Warning: This method is not thread-safe. If you call this method to stop a KVStore database that is running, your + * thread may crash. + * + *

The KVStore database to close must be an object created by using the {@code getKVStore} method. Before using this + * method, release the resources created for the database, for example, {@code KVStoreResultSet} for KVStore, otherwise + * closing the database will fail. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to close. + * @param {AsyncCallback} callback - the callback of closeKVStore. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeKVStore(appId: string, storeId: string, callback: AsyncCallback): void; + + /** + * Closes the KVStore database. + * + *

Warning: This method is not thread-safe. If you call this method to stop a KVStore database that is running, your + * thread may crash. + * + *

The KVStore database to close must be an object created by using the {@code getKVStore} method. Before using this + * method, release the resources created for the database, for example, {@code KVStoreResultSet} for KVStore, otherwise + * closing the database will fail. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to close. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeKVStore(appId: string, storeId: string): Promise; + + /** + * Deletes the KVStore database identified by storeId. + * + *

Before using this method, close all KVStore instances in use that are identified by the same storeId. + * + *

You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be + * lost. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to delete. + * @param {AsyncCallback} callback - the callback of deleteKVStore. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100004 - if the database not exist when delete database. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void; + + /** + * Deletes the KVStore database identified by storeId. + * + *

Before using this method, close all KVStore instances in use that are identified by the same storeId. + * + *

You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be + * lost. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to delete. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100004 - if the database not exist when delete database. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteKVStore(appId: string, storeId: string): Promise; + + /** + * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by + * calling the {@code deleteKVStore} method. + * + * @param {string} appId - Identifies the application that obtains the databases. + * @param {AsyncCallback} callback - {string[]}: the storeId of all created KVStore databases. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getAllKVStoreId(appId: string, callback: AsyncCallback): void; + + /** + * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by + * calling the {@code deleteKVStore} method. + * + * @param {string} appId - Identifies the application that obtains the databases. + * @returns {Promise} {string[]}: the storeId of all created KVStore databases. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getAllKVStoreId(appId: string): Promise; + + /** + * Register a death callback to get notification when service died. + * + * @param {Callback} deathCallback - the service died callback. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @throws {BusinessError} 401 - if parameter check failed. + * @since 9 + */ + on(event: 'distributedDataServiceDie', deathCallback: Callback): void; + + /** + * Unregister the death callback and can not receive service died notification any more. + * + * @param {Callback} deathCallback - the service died callback which has been registered. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; + } +} + +export default distributedKVStore; \ No newline at end of file