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