• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkData
19 */
20
21import { AsyncCallback, Callback } from './@ohos.base';
22
23/**
24 * Providers interfaces to creat a {@link KVManager} instance.
25 *
26 * @namespace distributedData
27 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
28 * @since 7
29 * @deprecated since 9
30 * @useinstead ohos.data.distributedKVStore
31 */
32declare namespace distributedData {
33  /**
34   * Provides configuration information for {@link KVManager} instances,
35   * including the caller's package name and distributed network type.
36   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
37   * @since 7
38   * @deprecated since 9
39   * @useinstead ohos.data.distributedKVStore.KVManagerConfig
40   */
41  interface KVManagerConfig {
42    /**
43     * Indicates the user information
44     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
45     * @since 7
46     * @deprecated since 9
47     */
48    userInfo: UserInfo;
49
50    /**
51     * Indicates the bundleName
52     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
53     * @since 7
54     * @deprecated since 9
55     * @useinstead ohos.data.distributedKVStore.KVManagerConfig#bundleName
56     */
57    bundleName: string;
58  }
59
60  /**
61   * Manages user information.
62   *
63   * <p>This class provides methods for obtaining the user ID and type, setting the user ID and type,
64   * and checking whether two users are the same.
65   *
66   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
67   * @since 7
68   * @deprecated since 9
69   */
70  interface UserInfo {
71    /**
72     * Indicates the user ID to set
73     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
74     * @since 7
75     * @deprecated since 9
76     */
77    userId?: string;
78
79    /**
80     * Indicates the user type to set
81     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
82     * @since 7
83     * @deprecated since 9
84     */
85    userType?: UserType;
86  }
87
88  /**
89   * Enumerates user types.
90   *
91   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
92   * @since 7
93   * @deprecated since 9
94   */
95  enum UserType {
96    /**
97     * Indicates a user that logs in to different devices using the same account.
98     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
99     * @since 7
100     * @deprecated since 9
101     */
102    SAME_USER_ID = 0
103  }
104
105  /**
106   * KVStore constants
107   *
108   * @namespace Constants
109   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
110   * @since 7
111   * @deprecated since 9
112   * @useinstead ohos.data.distributedKVStore.Constants
113   */
114  namespace Constants {
115    /**
116     * max key length.
117     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
118     * @since 7
119     * @deprecated since 9
120     * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH
121     */
122    const MAX_KEY_LENGTH = 1024;
123
124    /**
125     * max value length.
126     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
127     * @since 7
128     * @deprecated since 9
129     * @useinstead ohos.data.distributedKVStore.Constants#MAX_VALUE_LENGTH
130     */
131    const MAX_VALUE_LENGTH = 4194303;
132
133    /**
134     * max device coordinate key length.
135     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
136     * @since 7
137     * @deprecated since 9
138     * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH_DEVICEs
139     */
140    const MAX_KEY_LENGTH_DEVICE = 896;
141
142    /**
143     * max store id length.
144     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
145     * @since 7
146     * @deprecated since 9
147     * @useinstead ohos.data.distributedKVStore.Constants#MAX_STORE_ID_LENGTH
148     */
149    const MAX_STORE_ID_LENGTH = 128;
150
151    /**
152     * max query length.
153     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
154     * @since 7
155     * @deprecated since 9
156     * @useinstead ohos.data.distributedKVStore.Constants#MAX_QUERY_LENGTH
157     */
158    const MAX_QUERY_LENGTH = 512000;
159
160    /**
161     * max batch operation size.
162     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
163     * @since 7
164     * @deprecated since 9
165     * @useinstead ohos.data.distributedKVStore.Constants#MAX_BATCH_SIZE
166     */
167    const MAX_BATCH_SIZE = 128;
168  }
169
170  /**
171   * Indicates the {@code ValueType}.
172   *
173   * <p>{@code ValueType} is obtained based on the value.
174   *
175   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
176   * @since 7
177   * @deprecated since 9
178   * @useinstead ohos.data.distributedKVStore.ValueType
179   */
180  enum ValueType {
181    /**
182     * Indicates that the value type is string.
183     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
184     * @since 7
185     * @deprecated since 9
186     * @useinstead ohos.data.distributedKVStore.ValueType#STRING
187     */
188    STRING = 0,
189
190    /**
191     * Indicates that the value type is int.
192     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
193     * @since 7
194     * @deprecated since 9
195     * @useinstead ohos.data.distributedKVStore.ValueType#INTEGER
196     */
197    INTEGER = 1,
198
199    /**
200     * Indicates that the value type is float.
201     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
202     * @since 7
203     * @deprecated since 9
204     * @useinstead ohos.data.distributedKVStore.ValueType#FLOAT
205     */
206    FLOAT = 2,
207
208    /**
209     * Indicates that the value type is byte array.
210     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
211     * @since 7
212     * @deprecated since 9
213     * @useinstead ohos.data.distributedKVStore.ValueType#BYTE_ARRAY
214     * */
215    BYTE_ARRAY = 3,
216
217    /**
218     * Indicates that the value type is boolean.
219     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
220     * @since 7
221     * @deprecated since 9
222     * @useinstead ohos.data.distributedKVStore.ValueType#BOOLEAN
223     * */
224    BOOLEAN = 4,
225
226    /**
227     * Indicates that the value type is double.
228     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
229     * @since 7
230     * @deprecated since 9
231     * @useinstead ohos.data.distributedKVStore.ValueType#DOUBLE
232     */
233    DOUBLE = 5
234  }
235
236  /**
237   * Obtains {@code Value} objects stored in a {@link KVStore} database.
238   *
239   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
240   * @since 7
241   * @deprecated since 9
242   * @useinstead ohos.data.distributedKVStore.Value
243   */
244  interface Value {
245    /**
246     * Indicates value type
247     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
248     * @see ValueType
249     * @type {number}
250     * @memberof Value
251     * @since 7
252     * @deprecated since 9
253     * @useinstead ohos.data.distributedKVStore.Value#type
254     */
255    type: ValueType;
256    /**
257     * Indicates value
258     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
259     * @since 7
260     * @deprecated since 9
261     * @useinstead ohos.data.distributedKVStore.Value#value
262     */
263    value: Uint8Array | string | number | boolean;
264  }
265
266  /**
267   * Provides key-value pairs stored in the distributed database.
268   *
269   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
270   * @since 7
271   * @deprecated since 9
272   * @useinstead ohos.data.distributedKVStore.Entry
273   */
274  interface Entry {
275    /**
276     * Indicates key
277     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
278     * @since 7
279     * @deprecated since 9
280     * @useinstead ohos.data.distributedKVStore.Entry#key
281     */
282    key: string;
283    /**
284     * Indicates value
285     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
286     * @since 7
287     * @deprecated since 9
288     * @useinstead ohos.data.distributedKVStore.Entry#value
289     */
290    value: Value;
291  }
292
293  /**
294   * Receives notifications of all data changes, including data insertion, update, and deletion.
295   *
296   * <p>If you have subscribed to {@code KVStore}, you will receive data change notifications and obtain the changed data
297   * from the parameters in callback methods upon data insertion, update, or deletion.
298   *
299   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
300   * @since 7
301   * @deprecated since 9
302   * @useinstead ohos.data.distributedKVStore.ChangeNotification
303   */
304  interface ChangeNotification {
305    /**
306     * Indicates data addition records.
307     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
308     * @since 7
309     * @deprecated since 9
310     * @useinstead ohos.data.distributedKVStore.ChangeNotification#insertEntries
311     */
312    insertEntries: Entry[];
313    /**
314     * Indicates data update records.
315     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
316     * @since 7
317     * @deprecated since 9
318     * @useinstead ohos.data.distributedKVStore.ChangeNotification#updateEntries
319     */
320    updateEntries: Entry[];
321    /**
322     * Indicates data deletion records.
323     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
324     * @since 7
325     * @deprecated since 9
326     * @useinstead ohos.data.distributedKVStore.ChangeNotification#deleteEntries
327     */
328    deleteEntries: Entry[];
329    /**
330     * Indicates from device id.
331     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
332     * @since 7
333     * @deprecated since 9
334     * @useinstead ohos.data.distributedKVStore.ChangeNotification#deviceId
335     */
336    deviceId: string;
337  }
338
339  /**
340   * Indicates the database synchronization mode.
341   *
342   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
343   * @since 7
344   * @deprecated since 9
345   * @useinstead ohos.data.distributedKVStore.SyncMode
346   */
347  enum SyncMode {
348    /**
349     * Indicates that data is only pulled from the remote end.
350     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
351     * @since 7
352     * @deprecated since 9
353     * @useinstead ohos.data.distributedKVStore.SyncMode#PULL_ONLY
354     */
355    PULL_ONLY = 0,
356    /**
357     * Indicates that data is only pushed from the local end.
358     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
359     * @since 7
360     * @deprecated since 9
361     * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_ONLY
362     */
363    PUSH_ONLY = 1,
364    /**
365     * Indicates that data is pushed from the local end, and then pulled from the remote end.
366     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
367     * @since 7
368     * @deprecated since 9
369     * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_PULL
370     */
371    PUSH_PULL = 2
372  }
373
374  /**
375   * Describes the subscription type.
376   *
377   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
378   * @since 7
379   * @deprecated since 9
380   * @useinstead ohos.data.distributedKVStore.SubscribeType
381   */
382  enum SubscribeType {
383    /**
384     * Subscription to local data changes
385     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
386     * @since 7
387     * @deprecated since 9
388     * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_LOCAL
389     */
390    SUBSCRIBE_TYPE_LOCAL = 0,
391
392    /**
393     * Subscription to remote data changes
394     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
395     * @since 7
396     * @deprecated since 9
397     * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_REMOTE
398     */
399    SUBSCRIBE_TYPE_REMOTE = 1,
400
401    /**
402     * Subscription to both local and remote data changes
403     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
404     * @since 7
405     * @deprecated since 9
406     * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_ALL
407     */
408    SUBSCRIBE_TYPE_ALL = 2,
409  }
410
411  /**
412   * Describes the {@code KVStore} type.
413   *
414   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
415   * @since 7
416   * @deprecated since 9
417   * @useinstead ohos.data.distributedKVStore.KVStoreType
418   */
419  enum KVStoreType {
420    /**
421     * Device-collaboration database, as specified by {@code DeviceKVStore}
422     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
423     * @since 7
424     * @deprecated since 9
425     * @useinstead ohos.data.distributedKVStore.KVStoreType#DEVICE_COLLABORATION
426     */
427    DEVICE_COLLABORATION = 0,
428
429    /**
430     * Single-version database, as specified by {@code SingleKVStore}
431     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
432     * @since 7
433     * @deprecated since 9
434     * @useinstead ohos.data.distributedKVStore.KVStoreType#SINGLE_VERSION
435     */
436    SINGLE_VERSION = 1,
437
438    /**
439     * Multi-version database, as specified by {@code MultiKVStore}
440     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
441     * @since 7
442     * @deprecated since 9
443     */
444    MULTI_VERSION = 2,
445  }
446
447  /**
448   * Describes the {@code KVStore} type.
449   *
450   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
451   * @since 7
452   * @deprecated since 9
453   * @useinstead ohos.data.distributedKVStore.SecurityLevel
454   */
455  enum SecurityLevel {
456    /**
457     * NO_LEVEL: mains not set the security level.
458     *
459     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
460     * @since 7
461     * @deprecated since 9
462     */
463    NO_LEVEL = 0,
464
465    /**
466     * S0: mains the db is public.
467     * There is no impact even if the data is leaked.
468     *
469     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
470     * @since 7
471     * @deprecated since 9
472     */
473    S0 = 1,
474
475    /**
476     * S1: mains the db is low level security
477     * There are some low impact, when the data is leaked.
478     *
479     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
480     * @since 7
481     * @deprecated since 9
482     * @useinstead ohos.data.distributedKVStore.SecurityLevel#S1
483     */
484    S1 = 2,
485
486    /**
487     * S2: mains the db is middle level security
488     * There are some major impact, when the data is leaked.
489     *
490     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
491     * @since 7
492     * @deprecated since 9
493     * @useinstead ohos.data.distributedKVStore.SecurityLevel#S2
494     */
495    S2 = 3,
496
497    /**
498     * S3: mains the db is high level security
499     * There are some severity impact, when the data is leaked.
500     *
501     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
502     * @since 7
503     * @deprecated since 9
504     * @useinstead ohos.data.distributedKVStore.SecurityLevel#S3
505     */
506    S3 = 5,
507
508    /**
509     * S4: mains the db is critical level security
510     * There are some critical impact, when the data is leaked.
511     *
512     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
513     * @since 7
514     * @deprecated since 9
515     * @useinstead ohos.data.distributedKVStore.SecurityLevel#S4
516     */
517    S4 = 6,
518  }
519
520  /**
521   * Provides configuration options for creating a {@code KVStore}.
522   *
523   * <p>You can determine whether to create another database if a {@code KVStore} database is missing,
524   * whether to encrypt the database, and the database type.
525   *
526   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
527   * @since 7
528   * @deprecated since 9
529   * @useinstead ohos.data.distributedKVStore.Options
530   */
531  interface Options {
532    /**
533     * Indicates whether to create a database when the database file does not exist
534     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
535     * @since 7
536     * @deprecated since 9
537     * @useinstead ohos.data.distributedKVStore.Options#createIfMissing
538     */
539    createIfMissing?: boolean;
540    /**
541     * Indicates setting whether database files are encrypted
542     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
543     * @since 7
544     * @deprecated since 9
545     * @useinstead ohos.data.distributedKVStore.Options#encrypt
546     */
547    encrypt?: boolean;
548    /**
549     * Indicates setting whether to back up database files
550     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
551     * @since 7
552     * @deprecated since 9
553     * @useinstead ohos.data.distributedKVStore.Options#backup
554     */
555    backup?: boolean;
556    /**
557     * Indicates setting whether database files are automatically synchronized
558     * @permission ohos.permission.DISTRIBUTED_DATASYNC
559     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
560     * @since 7
561     * @deprecated since 9
562     * @useinstead ohos.data.distributedKVStore.Options#autoSync
563     */
564    autoSync?: boolean;
565    /**
566     * Indicates setting the database type
567     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
568     * @since 7
569     * @deprecated since 9
570     * @useinstead ohos.data.distributedKVStore.Options#kvStoreType
571     */
572    kvStoreType?: KVStoreType;
573    /**
574     * Indicates setting the database security level
575     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
576     * @since 7
577     * @deprecated since 9
578     * @useinstead ohos.data.distributedKVStore.Options#securityLevel
579     */
580    securityLevel?: SecurityLevel;
581    /**
582     * Indicates schema object
583     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
584     * @since 8
585     * @deprecated since 9
586     * @useinstead ohos.data.distributedKVStore.Options#schema
587     */
588    schema?: Schema;
589  }
590
591  /**
592   * Represents the database schema.
593   *
594   * You can create Schema objects and put them in Options when creating or opening the database.
595   *
596   * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
597   * @since 8
598   * @deprecated since 9
599   * @useinstead ohos.data.distributedKVStore.Schema
600   */
601  class Schema {
602    /**
603     * A constructor used to create a Schema instance.
604     *
605     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
606     * @since 8
607     * @deprecated since 9
608     * @useinstead ohos.data.distributedKVStore.Schema#constructor
609     */
610    constructor()
611
612    /**
613     * Indicates the root json object.
614     *
615     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
616     * @since 8
617     * @deprecated since 9
618     * @useinstead ohos.data.distributedKVStore.Schema#root
619     */
620    root: FieldNode;
621    /**
622     * Indicates the string array of json.
623     *
624     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
625     * @since 8
626     * @deprecated since 9
627     * @useinstead ohos.data.distributedKVStore.Schema#indexes
628     */
629    indexes: Array<string>;
630    /**
631     * Indicates the mode of schema.
632     *
633     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
634     * @since 8
635     * @deprecated since 9
636     * @useinstead ohos.data.distributedKVStore.Schema#mode
637     */
638    mode: number;
639    /**
640     * Indicates the skip size of schema.
641     *
642     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
643     * @since 8
644     * @deprecated since 9
645     * @useinstead ohos.data.distributedKVStore.Schema#skip
646     */
647    skip: number;
648  }
649
650  /**
651   * Represents a node of a {@link Schema} instance.
652   *
653   * <p>Through the {@link Schema} instance, you can define the fields contained in the values stored in a database.
654   *
655   * <p>A FieldNode of the {@link Schema} instance is either a leaf or a non-leaf node.
656   *
657   * <p>The leaf node must have a value; the non-leaf node must have a child {@code FieldNode}.
658   *
659   * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
660   * @since 8
661   * @deprecated since 9
662   * @useinstead ohos.data.distributedKVStore.FieldNode
663   */
664  class FieldNode {
665    /**
666     * A constructor used to create a FieldNode instance with the specified field.
667     * name Indicates the field node name.
668     *
669     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
670     * @since 8
671     * @deprecated since 9
672     * @useinstead ohos.data.distributedKVStore.FieldNode#constructor
673     */
674    constructor(name: string)
675
676    /**
677     * Adds a child node to this {@code FieldNode}.
678     *
679     * <p>Adding a child node makes this node a non-leaf node. Field value will be ignored if it has child node.
680     *
681     * @param child The field node to append.
682     * @returns Returns true if the child node is successfully added to this {@code FieldNode}; returns false otherwise.
683     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
684     * @since 8
685     * @deprecated since 9
686     * @useinstead ohos.data.distributedKVStore.FieldNode#appendChild
687     */
688    appendChild(child: FieldNode): boolean;
689
690    /**
691     * Indicates the default value of field node.
692     *
693     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
694     * @since 8
695     * @deprecated since 9
696     * @useinstead ohos.data.distributedKVStore.FieldNode#default
697     */
698    default: string;
699    /**
700     * Indicates the nullable of database field.
701     *
702     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
703     * @since 8
704     * @deprecated since 9
705     * @useinstead ohos.data.distributedKVStore.FieldNode#nullable
706     */
707    nullable: boolean;
708    /**
709     * Indicates the type of value.
710     *
711     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
712     * @since 8
713     * @deprecated since 9
714     * @useinstead ohos.data.distributedKVStore.FieldNode#type
715     */
716    type: number;
717  }
718
719  /**
720   * Provide methods to obtain the result set of the {@code KvStore} database.
721   *
722   * <p>The result set is created by using the {@code getResultSet} method in the {@code DeviceKVStore} class. This interface also provides
723   * methods for moving the data read position in the result set.
724   *
725   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
726   * @since 7
727   * @deprecated since 9
728   * @useinstead ohos.data.distributedKVStore.KVStoreResultSet
729   */
730  interface KvStoreResultSet {
731    /**
732     * Obtains the number of lines in a result set.
733     *
734     * @returns Returns the number of lines.
735     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
736     * @since 8
737     * @deprecated since 9
738     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getCount
739     */
740    getCount(): number;
741
742    /**
743     * Obtains the current read position in a result set.
744     *
745     * @returns Returns the current read position. The read position starts with 0.
746     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
747     * @since 8
748     * @deprecated since 9
749     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getPosition
750     */
751    getPosition(): number;
752
753    /**
754     * Moves the read position to the first line.
755     *
756     * <p>If the result set is empty, false is returned.
757     *
758     * @returns Returns true if the operation succeeds; return false otherwise.
759     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
760     * @since 8
761     * @deprecated since 9
762     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToFirst
763     */
764    moveToFirst(): boolean;
765
766    /**
767     * Moves the read position to the last line.
768     *
769     * <p>If the result set is empty, false is returned.
770     *
771     * @returns Returns true if the operation succeeds; return false otherwise.
772     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
773     * @since 8
774     * @deprecated since 9
775     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToLast
776     */
777    moveToLast(): boolean;
778
779    /**
780     * Moves the read position to the next line.
781     *
782     * <p>If the result set is empty or the data in the last line is being read, false is returned.
783     *
784     * @returns Returns true if the operation succeeds; return false otherwise.
785     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
786     * @since 8
787     * @deprecated since 9
788     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToNext
789     */
790    moveToNext(): boolean;
791
792    /**
793     * Moves the read position to the previous line.
794     *
795     * <p>If the result set is empty or the data in the first line is being read, false is returned.
796     *
797     * @returns Returns true if the operation succeeds; return false otherwise.
798     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
799     * @since 8
800     * @deprecated since 9
801     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPrevious
802     */
803    moveToPrevious(): boolean;
804
805    /**
806     * Moves the read position by a relative offset to the current position.
807     *
808     * @param offset Indicates the relative offset to the current position. A negative offset indicates moving backwards, and a
809     * positive offset indicates moving forwards. For example, if the current position is entry 1 and this offset is 2,
810     * the destination position will be entry 3; if the current position is entry 3 and this offset is -2,
811     * the destination position will be entry 1. The valid final position after moving forwards starts with 0. If the
812     * final position is invalid, false will be returned.
813     * @returns Returns true if the operation succeeds; return false otherwise.
814     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
815     * @since 8
816     * @deprecated since 9
817     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#move
818     */
819    move(offset: number): boolean;
820
821    /**
822     * Moves the read position from 0 to an absolute position.
823     *
824     * @param position Indicates the absolute position.
825     * @returns Returns true if the operation succeeds; return false otherwise.
826     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
827     * @since 8
828     * @deprecated since 9
829     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPosition
830     */
831    moveToPosition(position: number): boolean;
832
833    /**
834     * Checks whether the read position is the first line.
835     *
836     * @returns Returns true if the read position is the first line; returns false otherwise.
837     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
838     * @since 8
839     * @deprecated since 9
840     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isFirst
841     */
842    isFirst(): boolean;
843
844    /**
845     * Checks whether the read position is the last line.
846     *
847     * @returns Returns true if the read position is the last line; returns false otherwise.
848     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
849     * @since 8
850     * @deprecated since 9
851     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isLast
852     */
853    isLast(): boolean;
854
855    /**
856     * Checks whether the read position is before the last line.
857     *
858     * @returns Returns true if the read position is before the first line; returns false otherwise.
859     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
860     * @since 8
861     * @deprecated since 9
862     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isBeforeFirst
863     */
864    isBeforeFirst(): boolean;
865
866    /**
867     * Checks whether the read position is after the last line.
868     *
869     * @returns Returns true if the read position is after the last line; returns false otherwise.
870     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
871     * @since 8
872     * @deprecated since 9
873     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isAfterLast
874     */
875    isAfterLast(): boolean;
876
877    /**
878     * Obtains a key-value pair.
879     *
880     * @returns Returns a key-value pair.
881     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
882     * @since 8
883     * @deprecated since 9
884     * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getEntry
885     */
886    getEntry(): Entry;
887  }
888
889  /**
890   * Represents a database query using a predicate.
891   *
892   * <p>This class provides a constructor used to create a {@code Query} instance, which is used to query data matching specified
893   * conditions in the database.
894   *
895   * <p>This class also provides methods for adding predicates to the {@code Query} instance.
896   *
897   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
898   * @since 8
899   * @deprecated since 9
900   * @useinstead ohos.data.distributedKVStore.Query
901   */
902  class Query {
903    /**
904     * A constructor used to create a Query instance.
905     *
906     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
907     * @since 8
908     * @deprecated since 9
909     * @useinstead ohos.data.distributedKVStore.Query#constructor
910     */
911    constructor()
912
913    /**
914     * Resets this {@code Query} object.
915     *
916     * @returns Returns the reset {@code Query} object.
917     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
918     * @since 8
919     * @deprecated since 9
920     * @useinstead ohos.data.distributedKVStore.Query#reset
921     */
922    reset(): Query;
923
924    /**
925     * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value.
926     *
927     * @param field Indicates the field, which must start with $. and cannot contain ^.
928     * @param value IIndicates the long value.
929     * @returns Returns the {@coed Query} object.
930     * @throws Throws this exception if input is invalid.
931     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
932     * @since 8
933     * @deprecated since 9
934     * @useinstead ohos.data.distributedKVStore.Query#equalTo
935     */
936    equalTo(field: string, value: number | string | boolean): Query;
937
938    /**
939     * Constructs a {@code Query} object to query entries with the specified field whose value is not equal to the specified int value.
940     *
941     * @param field Indicates the field, which must start with $. and cannot contain ^.
942     * @param value Indicates the int value.
943     * @returns Returns the {@coed Query} object.
944     * @throws Throws this exception if input is invalid.
945     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
946     * @since 8
947     * @deprecated since 9
948     * @useinstead ohos.data.distributedKVStore.Query#notEqualTo
949     */
950    notEqualTo(field: string, value: number | string | boolean): Query;
951
952    /**
953     * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the
954     * specified int value.
955     *
956     * @param field Indicates the field, which must start with $. and cannot contain ^.
957     * @param value Indicates the int value.
958     * @returns Returns the {@coed Query} object.
959     * @throws Throws this exception if input is invalid.
960     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
961     * @since 8
962     * @deprecated since 9
963     * @useinstead ohos.data.distributedKVStore.Query#greaterThan
964     */
965    greaterThan(field: string, value: number | string | boolean): Query;
966
967    /**
968     * Constructs a {@code Query} object to query entries with the specified field whose value is less than the specified int value.
969     *
970     * @param field Indicates the field, which must start with $. and cannot contain ^.
971     * @param value Indicates the int value.
972     * @returns Returns the {@coed Query} object.
973     * @throws Throws this exception if input is invalid.
974     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
975     * @since 8
976     * @deprecated since 9
977     * @useinstead ohos.data.distributedKVStore.Query#lessThan
978     */
979    lessThan(field: string, value: number | string): Query;
980
981    /**
982     * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the
983     * specified int value.
984     *
985     * @param field Indicates the field, which must start with $. and cannot contain ^.
986     * @param value Indicates the int value.
987     * @returns Returns the {@coed Query} object.
988     * @throws Throws this exception if input is invalid.
989     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
990     * @since 8
991     * @deprecated since 9
992     * @useinstead ohos.data.distributedKVStore.Query#greaterThanOrEqualTo
993     */
994    greaterThanOrEqualTo(field: string, value: number | string): Query;
995
996    /**
997     * Constructs a {@code Query} object to query entries with the specified field whose value is less than or equal to the
998     * specified int value.
999     *
1000     * @param field Indicates the field, which must start with $. and cannot contain ^.
1001     * @param value Indicates the int value.
1002     * @returns Returns the {@coed Query} object.
1003     * @throws Throws this exception if input is invalid.
1004     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1005     * @since 8
1006     * @deprecated since 9
1007     * @useinstead ohos.data.distributedKVStore.Query#lessThanOrEqualTo
1008     */
1009    lessThanOrEqualTo(field: string, value: number | string): Query;
1010
1011    /**
1012     * Constructs a {@code Query} object to query entries with the specified field whose value is null.
1013     *
1014     * @param field Indicates the field, which must start with $. and cannot contain ^.
1015     * @returns Returns the {@coed Query} object.
1016     * @throws Throws this exception if input is invalid.
1017     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1018     * @since 8
1019     * @deprecated since 9
1020     * @useinstead ohos.data.distributedKVStore.Query#isNull
1021     */
1022    isNull(field: string): Query;
1023
1024    /**
1025     * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified int value list.
1026     *
1027     * @param field Indicates the field, which must start with $. and cannot contain ^.
1028     * @param valueList Indicates the int value list.
1029     * @returns Returns the {@coed Query} object.
1030     * @throws Throws this exception if input is invalid.
1031     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1032     * @since 8
1033     * @deprecated since 9
1034     * @useinstead ohos.data.distributedKVStore.Query#inNumber
1035     */
1036    inNumber(field: string, valueList: number[]): Query;
1037
1038    /**
1039     * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified string value list.
1040     *
1041     * @param field Indicates the field, which must start with $. and cannot contain ^.
1042     * @param valueList Indicates the string value list.
1043     * @returns Returns the {@coed Query} object.
1044     * @throws Throws this exception if input is invalid.
1045     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1046     * @since 8
1047     * @deprecated since 9
1048     * @useinstead ohos.data.distributedKVStore.Query#inString
1049     */
1050    inString(field: string, valueList: string[]): Query;
1051
1052    /**
1053     * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified int value list.
1054     *
1055     * @param field Indicates the field, which must start with $. and cannot contain ^.
1056     * @param valueList Indicates the int value list.
1057     * @returns Returns the {@coed Query} object.
1058     * @throws Throws this exception if input is invalid.
1059     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1060     * @since 8
1061     * @deprecated since 9
1062     * @useinstead ohos.data.distributedKVStore.Query#notInNumber
1063     */
1064    notInNumber(field: string, valueList: number[]): Query;
1065
1066    /**
1067     * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified string value list.
1068     *
1069     * @param field Indicates the field, which must start with $. and cannot contain ^.
1070     * @param valueList Indicates the string value list.
1071     * @returns Returns the {@coed Query} object.
1072     * @throws Throws this exception if input is invalid.
1073     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1074     * @since 8
1075     * @deprecated since 9
1076     * @useinstead ohos.data.distributedKVStore.Query#notInString
1077     */
1078    notInString(field: string, valueList: string[]): Query;
1079
1080    /**
1081     * Constructs a {@code Query} object to query entries with the specified field whose value is similar to the specified string value.
1082     *
1083     * @param field Indicates the field, which must start with $. and cannot contain ^.
1084     * @param value Indicates the string value.
1085     * @returns Returns the {@coed Query} object.
1086     * @throws Throws this exception if input is invalid.
1087     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1088     * @since 8
1089     * @deprecated since 9
1090     * @useinstead ohos.data.distributedKVStore.Query#like
1091     */
1092    like(field: string, value: string): Query;
1093
1094    /**
1095     * Constructs a {@code Query} object to query entries with the specified field whose value is not similar to the specified string value.
1096     *
1097     * @param field Indicates the field, which must start with $. and cannot contain ^.
1098     * @param value Indicates the string value.
1099     * @returns Returns the {@coed Query} object.
1100     * @throws Throws this exception if input is invalid.
1101     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1102     * @since 8
1103     * @deprecated since 9
1104     * @useinstead ohos.data.distributedKVStore.Query#unlike
1105     */
1106    unlike(field: string, value: string): Query;
1107
1108    /**
1109     * Constructs a {@code Query} object with the and condition.
1110     *
1111     * <p>Multiple predicates should be connected using the and or or condition.
1112     *
1113     * @returns Returns the {@coed Query} object.
1114     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1115     * @since 8
1116     * @deprecated since 9
1117     * @useinstead ohos.data.distributedKVStore.Query#and
1118     */
1119    and(): Query;
1120
1121    /**
1122     * Constructs a {@code Query} object with the or condition.
1123     *
1124     * <p>Multiple predicates should be connected using the and or or condition.
1125     *
1126     * @returns Returns the {@coed Query} object.
1127     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1128     * @since 8
1129     * @deprecated since 9
1130     * @useinstead ohos.data.distributedKVStore.Query#or
1131     */
1132    or(): Query;
1133
1134    /**
1135     * Constructs a {@code Query} object to sort the query results in ascending order.
1136     *
1137     * @param field Indicates the field, which must start with $. and cannot contain ^.
1138     * @returns Returns the {@coed Query} object.
1139     * @throws Throws this exception if input is invalid.
1140     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1141     * @since 8
1142     * @deprecated since 9
1143     * @useinstead ohos.data.distributedKVStore.Query#orderByAsc
1144     */
1145    orderByAsc(field: string): Query;
1146
1147    /**
1148     * Constructs a {@code Query} object to sort the query results in descending order.
1149     *
1150     * @param field Indicates the field, which must start with $. and cannot contain ^.
1151     * @returns Returns the {@coed Query} object.
1152     * @throws Throws this exception if input is invalid.
1153     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1154     * @since 8
1155     * @deprecated since 9
1156     * @useinstead ohos.data.distributedKVStore.Query#orderByDesc
1157     */
1158    orderByDesc(field: string): Query;
1159
1160    /**
1161     * Constructs a {@code Query} object to specify the number of results and the start position.
1162     *
1163     * @param total Indicates the number of results.
1164     * @param offset Indicates the start position.
1165     * @returns Returns the {@coed Query} object.
1166     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1167     * @since 8
1168     * @deprecated since 9
1169     * @useinstead ohos.data.distributedKVStore.Query#limit
1170     */
1171    limit(total: number, offset: number): Query;
1172
1173    /**
1174     * Creates a {@code query} condition with a specified field that is not null.
1175     *
1176     * @param field Indicates the specified field.
1177     * @returns Returns the {@coed Query} object.
1178     * @throws Throws this exception if input is invalid.
1179     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1180     * @since 8
1181     * @deprecated since 9
1182     * @useinstead ohos.data.distributedKVStore.Query#isNotNull
1183     */
1184    isNotNull(field: string): Query;
1185
1186    /**
1187     * Creates a query condition group with a left bracket.
1188     *
1189     * <p>Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a
1190     * whole to combine with other query conditions.
1191     *
1192     * @returns Returns the {@coed Query} object.
1193     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1194     * @since 8
1195     * @deprecated since 9
1196     * @useinstead ohos.data.distributedKVStore.Query#beginGroup
1197     */
1198    beginGroup(): Query;
1199
1200    /**
1201     * Creates a query condition group with a right bracket.
1202     *
1203     * <p>Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a
1204     * whole to combine with other query conditions.
1205     *
1206     * @returns Returns the {@coed Query} object.
1207     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1208     * @since 8
1209     * @deprecated since 9
1210     * @useinstead ohos.data.distributedKVStore.Query#endGroup
1211     */
1212    endGroup(): Query;
1213
1214    /**
1215     * Creates a query condition with a specified key prefix.
1216     *
1217     * @param prefix Indicates the specified key prefix.
1218     * @returns Returns the {@coed Query} object.
1219     * @throws Throws this exception if input is invalid.
1220     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1221     * @since 8
1222     * @deprecated since 9
1223     * @useinstead ohos.data.distributedKVStore.Query#prefixKey
1224     */
1225    prefixKey(prefix: string): Query;
1226
1227    /**
1228     * Sets a specified index that will be preferentially used for query.
1229     *
1230     * @param index Indicates the index to set.
1231     * @returns Returns the {@coed Query} object.
1232     * @throws Throws this exception if input is invalid.
1233     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1234     * @since 8
1235     * @deprecated since 9
1236     * @useinstead ohos.data.distributedKVStore.Query#setSuggestIndex
1237     */
1238    setSuggestIndex(index: string): Query;
1239
1240    /**
1241     * Add device ID key prefix.Used by {@code DeviceKVStore}.
1242     *
1243     * @param deviceId Specify device id to query from.
1244     * @returns Returns the {@code Query} object with device ID prefix added.
1245     * @throws Throws this exception if input is invalid.
1246     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1247     * @since 8
1248     * @deprecated since 9
1249     * @useinstead ohos.data.distributedKVStore.Query#deviceId
1250     */
1251    deviceId(deviceId: string): Query;
1252
1253    /**
1254     * Get a String that represents this {@code Query}.
1255     *
1256     * <p>The String would be parsed to DB query format.
1257     * The String length should be no longer than 500kb.
1258     *
1259     * @returns String representing this {@code Query}.
1260     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1261     * @since 8
1262     * @deprecated since 9
1263     * @useinstead ohos.data.distributedKVStore.Query#getSqlLike
1264     */
1265    getSqlLike(): string;
1266  }
1267
1268  /**
1269   * Represents a key-value distributed database and provides methods for adding, deleting, modifying, querying,
1270   * and subscribing to distributed data.
1271   *
1272   * <p>You can create distributed databases of different types by {@link KVManager#getKVStore (Options, String)}
1273   * with input parameter {@code Options}. Distributed database types are defined in {@code KVStoreType},
1274   * including {@code SingleKVStore}.
1275   *
1276   *
1277   * @version 1
1278   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1279   * @since 7
1280   * @deprecated since 9
1281   * @useinstead ohos.data.distributedKVStore.SingleKVStore
1282   */
1283  interface KVStore {
1284    /**
1285     * Writes a key-value pair of the string type into the {@code KvStore} database.
1286     *
1287     * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database.
1288     *
1289     * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}.
1290     * Spaces before and after the key will be cleared.
1291     * @param value Indicates the string value, which must be less than 4 MB as a UTF-8 byte array.
1292     * @throws Throws this exception if any of the following errors
1293     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1294     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1295     * @since 7
1296     * @deprecated since 9
1297     * @useinstead ohos.data.distributedKVStore.SingleKVStore#put
1298     */
1299    put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void;
1300
1301    /**
1302     * Writes a key-value pair of the string type into the {@code KvStore} database.
1303     *
1304     * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database.
1305     *
1306     * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}.
1307     * Spaces before and after the key will be cleared.
1308     * @param value Indicates the string value, which must be less than 4 MB as a UTF-8 byte array.
1309     * @throws Throws this exception if any of the following errors
1310     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1311     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1312     * @since 7
1313     * @deprecated since 9
1314     * @useinstead ohos.data.distributedKVStore.SingleKVStore#put
1315     */
1316    put(key: string, value: Uint8Array | string | number | boolean): Promise<void>;
1317
1318    /**
1319     * Deletes the key-value pair based on a specified key.
1320     *
1321     * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}.
1322     * Spaces before and after the key will be cleared.
1323     * @throws Throws this exception if any of the following errors
1324     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and
1325     * {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1326     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1327     * @since 7
1328     * @deprecated since 9
1329     * @useinstead ohos.data.distributedKVStore.SingleKVStore#delete
1330     */
1331    delete(key: string, callback: AsyncCallback<void>): void;
1332
1333    /**
1334     * Deletes the key-value pair based on a specified key.
1335     *
1336     * @param key Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}.
1337     * Spaces before and after the key will be cleared.
1338     * @throws Throws this exception if any of the following errors
1339     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and
1340     * {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1341     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1342     * @since 7
1343     * @deprecated since 9
1344     * @useinstead ohos.data.distributedKVStore.SingleKVStore#delete
1345     */
1346    delete(key: string): Promise<void>;
1347
1348    /**
1349     * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in
1350     * {@code KvStoreObserver} will be invoked.
1351     *
1352     * @param type Indicates the subscription type, which is defined in {@code SubscribeType}.
1353     * @param listener Indicates the observer of data change events in the distributed database.
1354     * @throws Throws this exception if any of the following errors
1355     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
1356     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1357     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1358     * @since 7
1359     * @deprecated since 9
1360     * @useinstead ohos.data.distributedKVStore.SingleKVStore#on
1361     */
1362    on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void;
1363
1364    /**
1365     * Subscribe the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}.
1366     *
1367     * @throws Throws this exception if any of the following errors
1368     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
1369     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1370     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1371     * @since 7
1372     * @deprecated since 9
1373     * @useinstead ohos.data.distributedKVStore.SingleKVStore#on
1374     */
1375    on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void;
1376
1377    /**
1378     * Unsubscribe the {@code KvStore} database based on the specified subscribeType and {@code KvStoreObserver}.
1379     *
1380     * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}.
1381     * @throws Throws this exception if any of the following errors
1382     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
1383     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1384     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1385     * @since 8
1386     * @deprecated since 9
1387     * @useinstead ohos.data.distributedKVStore.SingleKVStore#off
1388     */
1389    off(event: 'dataChange', listener?: Callback<ChangeNotification>): void;
1390
1391    /**
1392     * UnRegister the {@code KvStore} database synchronization callback.
1393     *
1394     * @param syncCallback Indicates the callback used to send the synchronization result to caller.
1395     * @throws Throws this exception if any of the following errors
1396     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
1397     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1398     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1399     * @since 8
1400     * @deprecated since 9
1401     * @useinstead ohos.data.distributedKVStore.SingleKVStore#off
1402     */
1403    off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void;
1404
1405    /**
1406     * Inserts key-value pairs into the {@code KvStore} database in batches.
1407     *
1408     * @param entries Indicates the key-value pairs to be inserted in batches.
1409     * @throws Throws this exception if a database error occurs.
1410     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1411     * @since 8
1412     * @deprecated since 9
1413     * @useinstead ohos.data.distributedKVStore.SingleKVStore#putBatch
1414     */
1415    putBatch(entries: Entry[], callback: AsyncCallback<void>): void;
1416
1417    /**
1418     * Inserts key-value pairs into the {@code KvStore} database in batches.
1419     *
1420     * @param entries Indicates the key-value pairs to be inserted in batches.
1421     * @throws Throws this exception if a database error occurs.
1422     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1423     * @since 8
1424     * @deprecated since 9
1425     * @useinstead ohos.data.distributedKVStore.SingleKVStore#putBatch
1426     */
1427    putBatch(entries: Entry[]): Promise<void>;
1428
1429    /**
1430     * Deletes key-value pairs in batches from the {@code KvStore} database.
1431     *
1432     * @param keys Indicates the key-value pairs to be deleted in batches.
1433     * @throws Throws this exception if a database error occurs.
1434     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1435     * @since 8
1436     * @deprecated since 9
1437     * @useinstead ohos.data.distributedKVStore.SingleKVStore#deleteBatch
1438     */
1439    deleteBatch(keys: string[], callback: AsyncCallback<void>): void;
1440
1441    /**
1442     * Deletes key-value pairs in batches from the {@code KvStore} database.
1443     *
1444     * @param keys Indicates the key-value pairs to be deleted in batches.
1445     * @throws Throws this exception if a database error occurs.
1446     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1447     * @since 8
1448     * @deprecated since 9
1449     * @useinstead ohos.data.distributedKVStore.SingleKVStore#deleteBatch
1450     */
1451    deleteBatch(keys: string[]): Promise<void>;
1452
1453    /**
1454     * Starts a transaction operation in the {@code KvStore} database.
1455     *
1456     * <p>After the database transaction is started, you can submit or roll back the operation.
1457     *
1458     * @throws Throws this exception if a database error occurs.
1459     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1460     * @since 8
1461     * @deprecated since 9
1462     * @useinstead ohos.data.distributedKVStore.SingleKVStore#startTransaction
1463     */
1464    startTransaction(callback: AsyncCallback<void>): void;
1465
1466    /**
1467     * Starts a transaction operation in the {@code KvStore} database.
1468     *
1469     * <p>After the database transaction is started, you can submit or roll back the operation.
1470     *
1471     * @throws Throws this exception if a database error occurs.
1472     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1473     * @since 8
1474     * @deprecated since 9
1475     * @useinstead ohos.data.distributedKVStore.SingleKVStore#startTransaction
1476     */
1477    startTransaction(): Promise<void>;
1478
1479    /**
1480     * Submits a transaction operation in the {@code KvStore} database.
1481     *
1482     * @param callback
1483     * @throws Throws this exception if a database error occurs.
1484     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1485     * @since 8
1486     * @deprecated since 9
1487     * @useinstead ohos.data.distributedKVStore.SingleKVStore#commit
1488     */
1489    commit(callback: AsyncCallback<void>): void;
1490
1491    /**
1492     * Submits a transaction operation in the {@code KvStore} database.
1493     *
1494     * @param callback
1495     * @throws Throws this exception if a database error occurs.
1496     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1497     * @since 8
1498     * @deprecated since 9
1499     * @useinstead ohos.data.distributedKVStore.SingleKVStore#commit
1500     */
1501    commit(): Promise<void>;
1502
1503    /**
1504     * Rolls back a transaction operation in the {@code KvStore} database.
1505     *
1506     * @throws Throws this exception if a database error occurs.
1507     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1508     * @since 8
1509     * @deprecated since 9
1510     * @useinstead ohos.data.distributedKVStore.SingleKVStore#rollback
1511     */
1512    rollback(callback: AsyncCallback<void>): void;
1513
1514    /**
1515     * Rolls back a transaction operation in the {@code KvStore} database.
1516     *
1517     * @throws Throws this exception if a database error occurs.
1518     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1519     * @since 8
1520     * @deprecated since 9
1521     * @useinstead ohos.data.distributedKVStore.SingleKVStore#rollback
1522     */
1523    rollback(): Promise<void>;
1524
1525    /**
1526     * Sets whether to enable synchronization.
1527     *
1528     * @param enabled Specifies whether to enable synchronization. The value true means to enable
1529     * synchronization, and false means the opposite.
1530     * @throws Throws this exception if an internal service error occurs.
1531     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1532     * @since 8
1533     * @deprecated since 9
1534     * @useinstead ohos.data.distributedKVStore.SingleKVStore#enableSync
1535     */
1536    enableSync(enabled: boolean, callback: AsyncCallback<void>): void;
1537
1538    /**
1539     * Sets whether to enable synchronization.
1540     *
1541     * @param enabled Specifies whether to enable synchronization. The value true means to enable
1542     * synchronization, and false means the opposite.
1543     * @throws Throws this exception if an internal service error occurs.
1544     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1545     * @since 8
1546     * @deprecated since 9
1547     * @useinstead ohos.data.distributedKVStore.SingleKVStore#enableSync
1548     */
1549    enableSync(enabled: boolean): Promise<void>;
1550
1551    /**
1552     * Sets synchronization range labels.
1553     *
1554     * <p>The labels determine the devices with which data will be synchronized.
1555     *
1556     * @param localLabels Indicates the synchronization labels of the local device.
1557     * @param remoteSupportLabels Indicates the labels of the devices with which data will be synchronized.
1558     * @throws Throws this exception if an internal service error occurs.
1559     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1560     * @since 8
1561     * @deprecated since 9
1562     * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncRange
1563     */
1564    setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback<void>): void;
1565
1566    /**
1567     * Sets synchronization range labels.
1568     *
1569     * <p>The labels determine the devices with which data will be synchronized.
1570     *
1571     * @param localLabels Indicates the synchronization labels of the local device.
1572     * @param remoteSupportLabels Indicates the labels of the devices with which data will be synchronized.
1573     * @throws Throws this exception if an internal service error occurs.
1574     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1575     * @since 8
1576     * @deprecated since 9
1577     * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncRange
1578     */
1579    setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<void>;
1580  }
1581
1582  /**
1583   * Provides methods related to single-version distributed databases.
1584   *
1585   * <p>To create a {@code SingleKVStore} database,
1586   * you can use the {@link data.distributed.common.KVManager#getKVStore​(Options, String)} method
1587   * with {@code KVStoreType} set to {@code SINGLE_VERSION} for the input parameter {@code Options}.
1588   * This database synchronizes data to other databases in time sequence.
1589   * The {@code SingleKVStore} database does not support
1590   * synchronous transactions, or data search using snapshots.
1591   *
1592   * @version 1
1593   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1594   * @since 7
1595   * @deprecated since 9
1596   * @useinstead ohos.data.distributedKVStore.SingleKVStore
1597   */
1598  interface SingleKVStore extends KVStore {
1599    /**
1600     * Obtains the {@code String} value of a specified key.
1601     *
1602     * @param key Indicates the key of the boolean value to be queried.
1603     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1604     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1605     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1606     * @since 7
1607     * @deprecated since 9
1608     * @useinstead ohos.data.distributedKVStore.SingleKVStore#get
1609     */
1610    get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void;
1611
1612    /**
1613     * Obtains the {@code String} value of a specified key.
1614     *
1615     * @param key Indicates the key of the boolean value to be queried.
1616     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1617     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1618     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1619     * @since 7
1620     * @deprecated since 9
1621     * @useinstead ohos.data.distributedKVStore.SingleKVStore#get
1622     */
1623    get(key: string): Promise<Uint8Array | string | boolean | number>;
1624
1625    /**
1626     * Obtains all key-value pairs that match a specified key prefix.
1627     *
1628     * @param keyPrefix Indicates the key prefix to match.
1629     * @returns Returns the list of all key-value pairs that match the specified key prefix.
1630     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1631     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1632     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1633     * @since 8
1634     * @deprecated since 9
1635     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries
1636     */
1637    getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void;
1638
1639    /**
1640     * Obtains all key-value pairs that match a specified key prefix.
1641     *
1642     * @param keyPrefix Indicates the key prefix to match.
1643     * @returns Returns the list of all key-value pairs that match the specified key prefix.
1644     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1645     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1646     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1647     * @since 8
1648     * @deprecated since 9
1649     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries
1650     */
1651    getEntries(keyPrefix: string): Promise<Entry[]>;
1652
1653    /**
1654     * Obtains the list of key-value pairs matching the specified {@code Query} object.
1655     *
1656     * @param query Indicates the {@code Query} object.
1657     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
1658     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1659     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1660     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1661     * @since 8
1662     * @deprecated since 9
1663     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries
1664     */
1665    getEntries(query: Query, callback: AsyncCallback<Entry[]>): void;
1666
1667    /**
1668     * Obtains the list of key-value pairs matching the specified {@code Query} object.
1669     *
1670     * @param query Indicates the {@code Query} object.
1671     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
1672     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1673     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1674     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1675     * @since 8
1676     * @deprecated since 9
1677     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries
1678     */
1679    getEntries(query: Query): Promise<Entry[]>;
1680
1681    /**
1682     * Obtains the result sets with a specified prefix from a {@code KvStore} database. The {@code KvStoreResultSet} object can be used to
1683     * query all key-value pairs that meet the search criteria. Each {@code KvStore} instance can have a maximum of four
1684     * {@code KvStoreResultSet} objects at the same time. If you have created four objects, calling this method will return a
1685     * failure. Therefore, you are advised to call the closeResultSet method to close unnecessary {@code KvStoreResultSet} objects
1686     * in a timely manner.
1687     *
1688     * @param keyPrefix Indicates the key prefix to match.
1689     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1690     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1691     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1692     * @since 8
1693     * @deprecated since 9
1694     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet
1695     */
1696    getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void;
1697
1698    /**
1699     * Obtains the result sets with a specified prefix from a {@code KvStore} database. The {@code KvStoreResultSet} object can be used to
1700     * query all key-value pairs that meet the search criteria. Each {@code KvStore} instance can have a maximum of four
1701     * {@code KvStoreResultSet} objects at the same time. If you have created four objects, calling this method will return a
1702     * failure. Therefore, you are advised to call the closeResultSet method to close unnecessary {@code KvStoreResultSet} objects
1703     * in a timely manner.
1704     *
1705     * @param keyPrefix Indicates the key prefix to match.
1706     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1707     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1708     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1709     * @since 8
1710     * @deprecated since 9
1711     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet
1712     */
1713    getResultSet(keyPrefix: string): Promise<KvStoreResultSet>;
1714
1715    /**
1716     * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object.
1717     *
1718     * @param query Indicates the {@code Query} object.
1719     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1720     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1721     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1722     * @since 8
1723     * @deprecated since 9
1724     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet
1725     */
1726    getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void;
1727
1728    /**
1729     * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object.
1730     *
1731     * @param query Indicates the {@code Query} object.
1732     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1733     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1734     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1735     * @since 8
1736     * @deprecated since 9
1737     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet
1738     */
1739    getResultSet(query: Query): Promise<KvStoreResultSet>;
1740
1741    /**
1742     * Closes a {@code KvStoreResultSet} object returned by getResultSet.
1743     *
1744     * @param resultSet Indicates the {@code KvStoreResultSet} object to close.
1745     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1746     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1747     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1748     * @since 8
1749     * @deprecated since 9
1750     * @useinstead ohos.data.distributedKVStore.SingleKVStore#closeResultSet
1751     */
1752    closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void;
1753
1754    /**
1755     * Closes a {@code KvStoreResultSet} object returned by getResultSet.
1756     *
1757     * @param resultSet Indicates the {@code KvStoreResultSet} object to close.
1758     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1759     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1760     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1761     * @since 8
1762     * @deprecated since 9
1763     * @useinstead ohos.data.distributedKVStore.SingleKVStore#closeResultSet
1764     */
1765    closeResultSet(resultSet: KvStoreResultSet): Promise<void>;
1766
1767    /**
1768     * Obtains the number of results matching the specified {@code Query} object.
1769     *
1770     * @param query Indicates the {@code Query} object.
1771     * @returns Returns the number of results matching the specified {@code Query} object.
1772     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1773     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1774     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1775     * @since 8
1776     * @deprecated since 9
1777     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSize
1778     */
1779    getResultSize(query: Query, callback: AsyncCallback<number>): void;
1780
1781    /**
1782     * Obtains the number of results matching the specified {@code Query} object.
1783     *
1784     * @param query Indicates the {@code Query} object.
1785     * @returns Returns the number of results matching the specified {@code Query} object.
1786     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1787     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1788     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1789     * @since 8
1790     * @deprecated since 9
1791     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSize
1792     */
1793    getResultSize(query: Query): Promise<number>;
1794
1795    /**
1796     * void removeDeviceData​({@link String} deviceId) throws {@link KvStoreException}
1797     *
1798     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1799     * @since 8
1800     * @deprecated since 9
1801     * @useinstead ohos.data.distributedKVStore.SingleKVStore#removeDeviceData
1802     */
1803    removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void;
1804
1805    /**
1806     * void removeDeviceData​({@link String} deviceId) throws {@link KvStoreException}
1807     *
1808     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1809     * @since 8
1810     * @deprecated since 9
1811     * @useinstead ohos.data.distributedKVStore.SingleKVStore#removeDeviceData
1812     */
1813    removeDeviceData(deviceId: string): Promise<void>;
1814
1815    /**
1816     * Synchronize the database to the specified devices with the specified delay allowed.
1817     *
1818     * @param deviceIds Indicates the list of devices to which to synchronize the database.
1819     * @param mode Indicates the synchronization mode. The value can be {@code PUSH}, {@code PULL}, or {@code PUSH_PULL}.
1820     * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds.
1821     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1822     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1823     * @permission ohos.permission.DISTRIBUTED_DATASYNC
1824     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1825     * @since 7
1826     * @deprecated since 9
1827     * @useinstead ohos.data.distributedKVStore.SingleKVStore#sync
1828     */
1829    sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void;
1830
1831    /**
1832     * Register a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback
1833     * in the {@code KvStoreObserver} will be invoked.
1834     *
1835     * @param type Indicates the subscription type, which is defined in {@code SubscribeType}.
1836     * @param listener Indicates the observer of data change events in the distributed database.
1837     * @throws Throws this exception if no {@code SingleKvStore} database is available.
1838     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1839     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1840     * @since 8
1841     * @deprecated since 9
1842     * @useinstead ohos.data.distributedKVStore.SingleKVStore#on
1843     */
1844    on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void;
1845
1846    /**
1847     * Register a SingleKvStore database synchronization callback.
1848     * <p> Sync result is returned through asynchronous callback.
1849     *
1850     * @param syncCallback Indicates the callback used to send the synchronization result to the caller.
1851     * @throws Throws this exception if no {@code SingleKvStore} database is available.
1852     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1853     * @since 8
1854     * @deprecated since 9
1855     * @useinstead ohos.data.distributedKVStore.SingleKVStore#on
1856     */
1857    on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void;
1858
1859    /**
1860     * Unsubscribe the SingleKvStore database based on the specified subscribeType and {@code KvStoreObserver}.
1861     *
1862     * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}.
1863     * @throws Throws this exception if any of the following errors
1864     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
1865     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
1866     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1867     * @since 8
1868     * @deprecated since 9
1869     * @useinstead ohos.data.distributedKVStore.SingleKVStore#off
1870     */
1871    off(event: 'dataChange', listener?: Callback<ChangeNotification>): void;
1872
1873    /**
1874     * UnRegister the SingleKvStore database synchronization callback.
1875     *
1876     * @throws Throws this exception if no {@code SingleKvStore} database is available.
1877     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1878     * @since 8
1879     * @deprecated since 9
1880     * @useinstead ohos.data.distributedKVStore.SingleKVStore#off
1881     */
1882    off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void;
1883
1884    /**
1885     * Sets the default delay allowed for database synchronization
1886     *
1887     * @param defaultAllowedDelayMs Indicates the default delay allowed for the database synchronization, in milliseconds.
1888     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1889     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1890     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1891     * @since 8
1892     * @deprecated since 9
1893     * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncParam
1894     */
1895    setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void;
1896
1897    /**
1898     * Sets the default delay allowed for database synchronization
1899     *
1900     * @param defaultAllowedDelayMs Indicates the default delay allowed for the database synchronization, in milliseconds.
1901     * @throws Throws this exception if any of the following errors occurs:{@code INVALID_ARGUMENT},
1902     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}.
1903     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1904     * @since 8
1905     * @deprecated since 9
1906     * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncParam
1907     */
1908    setSyncParam(defaultAllowedDelayMs: number): Promise<void>;
1909
1910    /**
1911     * Get the security level of the database.
1912     *
1913     * @returns SecurityLevel {@code SecurityLevel} the security level of the database.
1914     * @throws Throws this exception if any of the following errors occurs:{@code SERVER_UNAVAILABLE},
1915     * {@code IPC_ERROR}, and {@code DB_ERROR}.
1916     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1917     * @since 8
1918     * @deprecated since 9
1919     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getSecurityLevel
1920     */
1921    getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void;
1922
1923    /**
1924     * Get the security level of the database.
1925     *
1926     * @returns SecurityLevel {@code SecurityLevel} the security level of the database.
1927     * @throws Throws this exception if any of the following errors occurs:{@code SERVER_UNAVAILABLE},
1928     * {@code IPC_ERROR}, and {@code DB_ERROR}.
1929     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
1930     * @since 8
1931     * @deprecated since 9
1932     * @useinstead ohos.data.distributedKVStore.SingleKVStore#getSecurityLevel
1933     */
1934    getSecurityLevel(): Promise<SecurityLevel>;
1935  }
1936
1937  /**
1938   * Manages distributed data by device in a distributed system.
1939   *
1940   * <p>To create a {@code DeviceKVStore} database, you can use the {@link data.distributed.common.KVManager.getKvStore(Options, String)}
1941   * method with {@code KvStoreType} set to {@code DEVICE_COLLABORATION} for the input parameter Options. This database manages distributed
1942   * data by device, and cannot modify data synchronized from remote devices. When an application writes a key-value pair entry
1943   * into the database, the system automatically adds the ID of the device running the application to the key.
1944   *
1945   * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
1946   * @since 8
1947   * @deprecated since 9
1948   * @useinstead ohos.data.distributedKVStore.DeviceKVStore
1949   */
1950  interface DeviceKVStore extends KVStore {
1951    /**
1952     * Obtains the {@code String} value matching a specified device ID and key.
1953     *
1954     * @param deviceId Indicates the device to be queried.
1955     * @param key Indicates the key of the value to be queried.
1956     * @returns Returns the value matching the given criteria.
1957     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1958     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1959     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
1960     * @since 8
1961     * @deprecated since 9
1962     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#get
1963     */
1964    get(deviceId: string, key: string, callback: AsyncCallback<boolean | string | number | Uint8Array>): void;
1965
1966    /**
1967     * Obtains the {@code String} value matching a specified device ID and key.
1968     *
1969     * @param deviceId Indicates the device to be queried.
1970     * @param key Indicates the key of the value to be queried.
1971     * @returns Returns the value matching the given criteria.
1972     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1973     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}, and {@code KEY_NOT_FOUND}.
1974     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
1975     * @since 8
1976     * @deprecated since 9
1977     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#get
1978     */
1979    get(deviceId: string, key: string): Promise<boolean | string | number | Uint8Array>;
1980
1981    /**
1982     * Obtains all key-value pairs matching a specified device ID and key prefix.
1983     *
1984     * @param deviceId Identifies the device whose data is to be queried.
1985     * @param keyPrefix Indicates the key prefix to match.
1986     * @returns Returns the list of all key-value pairs meeting the given criteria.
1987     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
1988     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
1989     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
1990     * @since 8
1991     * @deprecated since 9
1992     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
1993     */
1994    getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void;
1995
1996    /**
1997     * Obtains all key-value pairs matching a specified device ID and key prefix.
1998     *
1999     * @param deviceId Identifies the device whose data is to be queried.
2000     * @param keyPrefix Indicates the key prefix to match.
2001     * @returns Returns the list of all key-value pairs meeting the given criteria.
2002     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2003     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2004     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2005     * @since 8
2006     * @deprecated since 9
2007     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
2008     */
2009    getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]>;
2010
2011    /**
2012     * Obtains the list of key-value pairs matching the specified {@code Query} object.
2013     *
2014     * @param query Indicates the {@code Query} object.
2015     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
2016     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2017     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2018     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2019     * @since 8
2020     * @deprecated since 9
2021     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
2022     */
2023    getEntries(query: Query, callback: AsyncCallback<Entry[]>): void;
2024
2025    /**
2026     * Obtains the list of key-value pairs matching the specified {@code Query} object.
2027     *
2028     * @param query Indicates the {@code Query} object.
2029     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
2030     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2031     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2032     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2033     * @since 8
2034     * @deprecated since 9
2035     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
2036     */
2037    getEntries(query: Query): Promise<Entry[]>;
2038
2039    /**
2040     * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object.
2041     *
2042     * @param deviceId Indicates the ID of the device to which the key-value pairs belong.
2043     * @param query Indicates the {@code Query} object.
2044     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
2045     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2046     * @since 8
2047     * @deprecated since 9
2048     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
2049     */
2050    getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void;
2051
2052    /**
2053     * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object.
2054     *
2055     * @param deviceId Indicates the ID of the device to which the key-value pairs belong.
2056     * @param query Indicates the {@code Query} object.
2057     * @returns Returns the list of key-value pairs matching the specified {@code Query} object.
2058     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2059     * @since 8
2060     * @deprecated since 9
2061     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries
2062     */
2063    getEntries(deviceId: string, query: Query): Promise<Entry[]>;
2064
2065    /**
2066     * Obtains the {@code KvStoreResultSet} object matching the specified device ID and key prefix.
2067     *
2068     * <p>The {@code KvStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code KvStore}
2069     * instance can have a maximum of four {@code KvStoreResultSet} objects at the same time. If you have created four objects,
2070     * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary
2071     * {@code KvStoreResultSet} objects in a timely manner.
2072     *
2073     * @param deviceId Identifies the device whose data is to be queried.
2074     * @param keyPrefix Indicates the key prefix to match.
2075     * @returns Returns the {@code KvStoreResultSet} objects.
2076     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2077     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2078     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2079     * @since 8
2080     * @deprecated since 9
2081     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2082     */
2083    getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void;
2084
2085    /**
2086     * Obtains the {@code KvStoreResultSet} object matching the specified device ID and key prefix.
2087     *
2088     * <p>The {@code KvStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code KvStore}
2089     * instance can have a maximum of four {@code KvStoreResultSet} objects at the same time. If you have created four objects,
2090     * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary
2091     * {@code KvStoreResultSet} objects in a timely manner.
2092     *
2093     * @param deviceId Identifies the device whose data is to be queried.
2094     * @param keyPrefix Indicates the key prefix to match.
2095     * @returns Returns the {@code KvStoreResultSet} objects.
2096     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2097     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2098     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2099     * @since 8
2100     * @deprecated since 9
2101     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2102     */
2103    getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet>;
2104
2105    /**
2106     * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2107     *
2108     * @param query Indicates the {@code Query} object.
2109     * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2110     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2111     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2112     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2113     * @since 8
2114     * @deprecated since 9
2115     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2116     */
2117    getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void;
2118
2119    /**
2120     * Obtains the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2121     *
2122     * @param query Indicates the {@code Query} object.
2123     * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2124     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2125     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2126     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2127     * @since 8
2128     * @deprecated since 9
2129     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2130     */
2131    getResultSet(query: Query): Promise<KvStoreResultSet>;
2132
2133    /**
2134     * Obtains the {@code KvStoreResultSet} object matching a specified device ID and {@code Query} object.
2135     *
2136     * @param deviceId Indicates the ID of the device to which the {@code KvStoreResultSet} object belongs.
2137     * @param query Indicates the {@code Query} object.
2138     * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2139     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2140     * @since 8
2141     * @deprecated since 9
2142     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2143     */
2144    getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreResultSet>): void;
2145
2146    /**
2147     * Obtains the {@code KvStoreResultSet} object matching a specified device ID and {@code Query} object.
2148     *
2149     * @param deviceId Indicates the ID of the device to which the {@code KvStoreResultSet} object belongs.
2150     * @param query Indicates the {@code Query} object.
2151     * @returns Returns the {@code KvStoreResultSet} object matching the specified {@code Query} object.
2152     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2153     * @since 8
2154     * @deprecated since 9
2155     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet
2156     */
2157    getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet>;
2158
2159    /**
2160     * Closes a {@code KvStoreResultSet} object returned by getResultSet.
2161     *
2162     * @param resultSet Indicates the {@code KvStoreResultSet} object to close.
2163     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2164     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2165     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2166     * @since 8
2167     * @deprecated since 9
2168     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#closeResultSet
2169     */
2170    closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void;
2171
2172    /**
2173     * Closes a {@code KvStoreResultSet} object returned by getResultSet.
2174     *
2175     * @param resultSet Indicates the {@code KvStoreResultSet} object to close.
2176     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2177     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2178     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2179     * @since 8
2180     * @deprecated since 9
2181     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#closeResultSet
2182     */
2183    closeResultSet(resultSet: KvStoreResultSet): Promise<void>;
2184
2185    /**
2186     * Obtains the number of results matching the specified {@code Query} object.
2187     *
2188     * @param query Indicates the {@code Query} object.
2189     * @returns Returns the number of results matching the specified {@code Query} object.
2190     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2191     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2192     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2193     * @since 8
2194     * @deprecated since 9
2195     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize
2196     */
2197    getResultSize(query: Query, callback: AsyncCallback<number>): void;
2198
2199    /**
2200     * Obtains the number of results matching the specified {@code Query} object.
2201     *
2202     * @param query Indicates the {@code Query} object.
2203     * @returns Returns the number of results matching the specified {@code Query} object.
2204     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2205     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2206     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2207     * @since 8
2208     * @deprecated since 9
2209     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize
2210     */
2211    getResultSize(query: Query): Promise<number>;
2212
2213    /**
2214     * Obtains the number of results matching a specified device ID and {@code Query} object.
2215     *
2216     * @param deviceId Indicates the ID of the device to which the results belong.
2217     * @param query Indicates the {@code Query} object.
2218     * @returns Returns the number of results matching the specified {@code Query} object.
2219     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2220     * @since 8
2221     * @deprecated since 9
2222     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize
2223     */
2224    getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void;
2225
2226    /**
2227     * Obtains the number of results matching a specified device ID and {@code Query} object.
2228     *
2229     * @param deviceId Indicates the ID of the device to which the results belong.
2230     * @param query Indicates the {@code Query} object.
2231     * @returns Returns the number of results matching the specified {@code Query} object.
2232     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2233     * @since 8
2234     * @deprecated since 9
2235     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize
2236     */
2237    getResultSize(deviceId: string, query: Query): Promise<number>;
2238
2239    /**
2240     * Removes data of a specified device from the current database. This method is used to remove only the data
2241     * synchronized from remote devices. This operation does not synchronize data to other databases or affect
2242     * subsequent data synchronization.
2243     *
2244     * @param deviceId Identifies the device whose data is to be removed. The value cannot be the current device ID.
2245     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2246     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2247     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2248     * @since 8
2249     * @deprecated since 9
2250     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#removeDeviceData
2251     */
2252    removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void;
2253
2254    /**
2255     * Removes data of a specified device from the current database. This method is used to remove only the data
2256     * synchronized from remote devices. This operation does not synchronize data to other databases or affect
2257     * subsequent data synchronization.
2258     *
2259     * @param deviceId Identifies the device whose data is to be removed. The value cannot be the current device ID.
2260     * @throws Throws this exception if any of the following errors occurs: {@code INVALID_ARGUMENT},
2261     * {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, {@code DB_ERROR}.
2262     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2263     * @since 8
2264     * @deprecated since 9
2265     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#removeDeviceData
2266     */
2267    removeDeviceData(deviceId: string): Promise<void>;
2268
2269    /**
2270     * Synchronize the {@code DeviceKVStore} databases.
2271     *
2272     * <p>This method returns immediately and sync result will be returned through asynchronous callback.
2273     *
2274     * @permission ohos.permission.DISTRIBUTED_DATASYNC
2275     * @param deviceIds Indicates the list of IDs of devices whose
2276     * @param delayMs Indicates the delay allowed for the synchronization, in milliseconds.
2277     * {@code DeviceKVStore} databases are to be synchronized.
2278     * @param mode Indicates the synchronization mode, {@code PUSH}, {@code PULL}, or
2279     * {@code PUSH_PULL}.
2280     * @throws Throws this exception if no DeviceKVStore database is available.
2281     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2282     * @since 8
2283     * @deprecated since 9
2284     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#sync
2285     */
2286    sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void;
2287
2288    /**
2289     * Register a {@code KvStoreObserver} for the database. When data in the distributed database changes, the
2290     * callback in the {@code KvStoreObserver} will be invoked.
2291     *
2292     * @param type Indicates the subscription type, which is defined in {@code SubscribeType}.
2293     * @param listener Indicates the observer of data change events in the distributed database.
2294     * @throws Throws this exception if any of the following errors
2295     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
2296     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
2297     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2298     * @since 8
2299     * @deprecated since 9
2300     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#on
2301     */
2302    on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void;
2303
2304
2305    /**
2306     * Register a DeviceKVStore database synchronization callback.
2307     *
2308     * <p>Sync result is returned through asynchronous callback.
2309     *
2310     * @param syncCallback Indicates the callback used to send the synchronization result to the caller.
2311     * @throws Throws this exception if no DeviceKVStore database is available.
2312     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2313     * @since 8
2314     * @deprecated since 9
2315     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#on
2316     */
2317    on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void;
2318
2319    /**
2320     * Unsubscribe the DeviceKVStore database based on the specified subscribeType and {@code KvStoreObserver}.
2321     *
2322     * @param listener Indicates the data change observer registered by {#subscribe(SubscribeType, KvStoreObserver)}.
2323     * @throws Throws this exception if any of the following errors
2324     * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR},
2325     * {@code DB_ERROR}, and {@code STORE_ALREADY_SUBSCRIBE}.
2326     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2327     * @since 8
2328     * @deprecated since 9
2329     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#off
2330     */
2331    off(event: 'dataChange', listener?: Callback<ChangeNotification>): void;
2332
2333    /**
2334     * UnRegister the DeviceKVStore database synchronization callback.
2335     *
2336     * @throws Throws this exception if no DeviceKVStore database is available.
2337     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2338     * @since 8
2339     * @deprecated since 9
2340     * @useinstead ohos.data.distributedKVStore.DeviceKVStore#off
2341     */
2342    off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void;
2343  }
2344
2345  /**
2346   * Creates a {@link KVManager} instance based on the configuration information.
2347   *
2348   * <p>You must pass {@link KVManagerConfig} to provide configuration information
2349   * for creating the {@link KVManager} instance.
2350   *
2351   * @param config Indicates the {@link KVStore} configuration information,
2352   * including the user information and package name.
2353   * @returns Returns the {@code KVManager} instance.
2354   * @throws Throws exception if input is invalid.
2355   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2356   * @since 7
2357   * @deprecated since 9
2358   * @useinstead ohos.data.distributedKVStore#createKVManager
2359   */
2360  function createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void;
2361
2362  /**
2363   * Creates a {@link KVManager} instance based on the configuration information.
2364   *
2365   * <p>You must pass {@link KVManagerConfig} to provide configuration information
2366   * for creating the {@link KVManager} instance.
2367   *
2368   * @param config Indicates the {@link KVStore} configuration information,
2369   * including the user information and package name.
2370   * @returns Returns the {@code KVManager} instance.
2371   * @throws Throws exception if input is invalid.
2372   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2373   * @since 7
2374   * @deprecated since 9
2375   * @useinstead ohos.data.distributedKVStore#createKVManager
2376   */
2377  function createKVManager(config: KVManagerConfig): Promise<KVManager>;
2378
2379  /**
2380   * Provides interfaces to manage a {@code KVStore} database, including obtaining, closing, and deleting the {@code KVStore}.
2381   *
2382   * @version 1
2383   * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2384   * @since 7
2385   * @deprecated since 9
2386   * @useinstead ohos.data.distributedKVStore.KVManager
2387   */
2388  interface KVManager {
2389    /**
2390     * Creates and obtains a {@code KVStore} database by specifying {@code Options} and {@code storeId}.
2391     *
2392     * @param options Indicates the options used for creating and obtaining the {@code KVStore} database,
2393     * including {@code isCreateIfMissing}, {@code isEncrypt}, and {@code KVStoreType}.
2394     * @param storeId Identifies the {@code KVStore} database.
2395     * The value of this parameter must be unique for the same application,
2396     * and different applications can share the same value.
2397     * @returns Returns a {@code KVStore}, or {@code SingleKVStore}.
2398     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2399     * @since 7
2400     * @deprecated since 9
2401     * @useinstead ohos.data.distributedKVStore.KVManager#getKVStore
2402     */
2403    getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T>;
2404
2405    /**
2406     * Creates and obtains a {@code KVStore} database by specifying {@code Options} and {@code storeId}.
2407     *
2408     * @param options Indicates the options used for creating and obtaining the {@code KVStore} database,
2409     * including {@code isCreateIfMissing}, {@code isEncrypt}, and {@code KVStoreType}.
2410     * @param storeId Identifies the {@code KVStore} database.
2411     * The value of this parameter must be unique for the same application,
2412     * and different applications can share the same value.
2413     * @returns Returns a {@code KVStore}, or {@code SingleKVStore}.
2414     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2415     * @since 7
2416     * @deprecated since 9
2417     * @useinstead ohos.data.distributedKVStore.KVManager#getKVStore
2418     */
2419    getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void;
2420
2421    /**
2422     * Closes the {@code KvStore} database.
2423     *
2424     * <p>Warning: This method is not thread-safe. If you call this method to stop a KvStore database that is running, your
2425     * thread may crash.
2426     *
2427     * <p>The {@code KvStore} database to close must be an object created by using the {@code getKvStore} method. Before using this
2428     * method, release the resources created for the database, for example, {@code KvStoreResultSet} for {@code SingleKvStore},
2429     * otherwise closing the database will fail. If you are attempting to close a database that is already closed, an error
2430     * will be returned.
2431     *
2432     * @param kvStore Indicates the {@code KvStore} database to close.
2433     * @throws Throws this exception if any of the following errors
2434     * occurs:{@code INVALID_ARGUMENT}, {@code SERVER_UNAVAILABLE},
2435     * {@code STORE_NOT_OPEN}, {@code STORE_NOT_FOUND}, {@code DB_ERROR},
2436     * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2437     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2438     * @since 8
2439     * @deprecated since 9
2440     * @useinstead ohos.data.distributedKVStore.KVManager#closeKVStore
2441     */
2442    closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback<void>): void;
2443
2444    /**
2445     * Closes the {@code KvStore} database.
2446     *
2447     * <p>Warning: This method is not thread-safe. If you call this method to stop a KvStore database that is running, your
2448     * thread may crash.
2449     *
2450     * <p>The {@code KvStore} database to close must be an object created by using the {@code getKvStore} method. Before using this
2451     * method, release the resources created for the database, for example, {@code KvStoreResultSet} for {@code SingleKvStore},
2452     * otherwise closing the database will fail. If you are attempting to close a database that is already closed, an error
2453     * will be returned.
2454     *
2455     * @param kvStore Indicates the {@code KvStore} database to close.
2456     * @throws Throws this exception if any of the following errors
2457     * occurs:{@code INVALID_ARGUMENT}, {@code SERVER_UNAVAILABLE},
2458     * {@code STORE_NOT_OPEN}, {@code STORE_NOT_FOUND}, {@code DB_ERROR},
2459     * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2460     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2461     * @since 8
2462     * @deprecated since 9
2463     * @useinstead ohos.data.distributedKVStore.KVManager#closeKVStore
2464     */
2465    closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void>;
2466
2467    /**
2468     * Deletes the {@code KvStore} database identified by storeId.
2469     *
2470     * <p>Before using this method, close all {@code KvStore} instances in use that are identified by the same storeId.
2471     *
2472     * <p>You can use this method to delete a {@code KvStore} database not in use. After the database is deleted, all its data will be
2473     * lost.
2474     *
2475     * @param storeId Identifies the {@code KvStore} database to delete.
2476     * @throws Throws this exception if any of the following errors
2477     * occurs: {@code INVALID_ARGUMENT},
2478     * {@code SERVER_UNAVAILABLE}, {@code STORE_NOT_FOUND},
2479     * {@code DB_ERROR}, {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2480     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2481     * @since 8
2482     * @deprecated since 9
2483     * @useinstead ohos.data.distributedKVStore.KVManager#deleteKVStore
2484     */
2485    deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void;
2486
2487    /**
2488     * Deletes the {@code KvStore} database identified by storeId.
2489     *
2490     * <p>Before using this method, close all {@code KvStore} instances in use that are identified by the same storeId.
2491     *
2492     * <p>You can use this method to delete a {@code KvStore} database not in use. After the database is deleted, all its data will be
2493     * lost.
2494     *
2495     * @param storeId Identifies the {@code KvStore} database to delete.
2496     * @throws Throws this exception if any of the following errors
2497     * occurs: {@code INVALID_ARGUMENT},
2498     * {@code SERVER_UNAVAILABLE}, {@code STORE_NOT_FOUND},
2499     * {@code DB_ERROR}, {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2500     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2501     * @since 8
2502     * @deprecated since 9
2503     * @useinstead ohos.data.distributedKVStore.KVManager#deleteKVStore
2504     */
2505    deleteKVStore(appId: string, storeId: string): Promise<void>;
2506
2507    /**
2508     * Obtains the storeId of all {@code KvStore} databases that are created by using the {@code getKvStore} method and not deleted by
2509     * calling the {@code deleteKvStore} method.
2510     *
2511     * @returns Returns the storeId of all created {@code KvStore} databases.
2512     * @throws Throws this exception if any of the following errors
2513     * occurs: {@code SERVER_UNAVAILABLE}, {@code DB_ERROR},
2514     * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2515     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2516     * @since 8
2517     * @deprecated since 9
2518     * @useinstead ohos.data.distributedKVStore.KVManager#getAllKVStoreId
2519     */
2520    getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void;
2521
2522    /**
2523     * Obtains the storeId of all {@code KvStore} databases that are created by using the {@code getKvStore} method and not deleted by
2524     * calling the {@code deleteKvStore} method.
2525     *
2526     * @returns Returns the storeId of all created {@code KvStore} databases.
2527     * @throws Throws this exception if any of the following errors
2528     * occurs: {@code SERVER_UNAVAILABLE}, {@code DB_ERROR},
2529     * {@code PERMISSION_DENIED}, and {@code IPC_ERROR}.
2530     * @syscap SystemCapability.DistributedDataManager.KVStore.Core
2531     * @since 8
2532     * @deprecated since 9
2533     * @useinstead ohos.data.distributedKVStore.KVManager#getAllKVStoreId
2534     */
2535    getAllKVStoreId(appId: string): Promise<string[]>;
2536
2537    /**
2538     * register DeviceChangeCallback to get notification when device's status changed
2539     *
2540     * @param deathCallback device change callback {@code DeviceChangeCallback}
2541     * @throws    exception maybe occurs.
2542     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2543     * @since 8
2544     * @deprecated since 9
2545     * @useinstead ohos.data.distributedKVStore.KVManager#on
2546     */
2547    on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void;
2548
2549    /**
2550     * unRegister DeviceChangeCallback and can not receive notification
2551     *
2552     * @param deathCallback device change callback {@code DeviceChangeCallback} which has been registered.
2553     * @throws exception maybe occurs.
2554     * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2555     * @since 8
2556     * @deprecated since 9
2557     * @useinstead ohos.data.distributedKVStore.KVManager#off
2558     */
2559    off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void;
2560  }
2561}
2562
2563/**
2564 * Providers interfaces to creat a {@link KVManager} instance.
2565 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
2566 * @since 7
2567 * @deprecated since 9
2568 */
2569export default distributedData;