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 16/** 17 * @file 18 * @kit ArkData 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22import { ValuesBucket } from './@ohos.data.ValuesBucket'; 23import dataSharePredicates from './@ohos.data.dataSharePredicates'; 24import BaseContext from './application/BaseContext'; 25 26/** 27 * Provider interfaces to create a {@link KVManager} instance. 28 * 29 * @namespace distributedKVStore 30 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 31 * @since 9 32 */ 33declare namespace distributedKVStore { 34 /** 35 * Provides configuration information to create a {@link KVManager} instance, 36 * which includes the caller's package name and ability or hap context. 37 * 38 * @interface KVManagerConfig 39 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 40 * @since 9 41 */ 42 interface KVManagerConfig { 43 /** 44 * Indicates the bundleName 45 * 46 * @type { string } 47 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 48 * @since 9 49 */ 50 bundleName: string; 51 52 /** 53 * Indicates the ability or hap context 54 * 55 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 56 * if swap the area, you should close all the KV store and use the new Context to create the KVManager 57 * @since 9 58 */ 59 /** 60 * Indicates the ability or hap context 61 * 62 * @type { BaseContext } 63 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 64 * if swap the area, you should close all the KV store and use the new BaseContext to create the KVManager 65 * @since 10 66 */ 67 context: BaseContext; 68 } 69 70 /** 71 * KVStore constants 72 * 73 * @interface Constants 74 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 75 * @since 9 76 */ 77 interface Constants { 78 /** 79 * Max key length is 1024. 80 * 81 * @type { number } 82 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 83 * @since 9 84 */ 85 readonly MAX_KEY_LENGTH: number; 86 87 /** 88 * Max value length is 4194303. 89 * 90 * @type { number } 91 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 92 * @since 9 93 */ 94 readonly MAX_VALUE_LENGTH: number; 95 96 /** 97 * Max device coordinate key length is 896. 98 * 99 * @type { number } 100 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 101 * @since 9 102 */ 103 readonly MAX_KEY_LENGTH_DEVICE: number; 104 105 /** 106 * Max store id length is 128. 107 * 108 * @type { number } 109 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 110 * @since 9 111 */ 112 readonly MAX_STORE_ID_LENGTH: number; 113 114 /** 115 * Max query length is 512000. 116 * 117 * @type { number } 118 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 119 * @since 9 120 */ 121 readonly MAX_QUERY_LENGTH: number; 122 123 /** 124 * Max batch operation size is 128. 125 * 126 * @type { number } 127 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 128 * @since 9 129 */ 130 readonly MAX_BATCH_SIZE: number; 131 } 132 133 /** 134 * Indicates the {@code ValueType}. 135 * <p>{@code ValueType} is obtained based on the value. 136 * 137 * @enum { number } 138 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 139 * @since 9 140 */ 141 enum ValueType { 142 /** 143 * Indicates that the value type is string. 144 * 145 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 146 * @since 9 147 */ 148 STRING, 149 150 /** 151 * Indicates that the value type is int. 152 * 153 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 154 * @since 9 155 */ 156 INTEGER, 157 158 /** 159 * Indicates that the value type is float. 160 * 161 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 162 * @since 9 163 */ 164 FLOAT, 165 166 /** 167 * Indicates that the value type is byte array. 168 * 169 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 170 * @since 9 171 */ 172 BYTE_ARRAY, 173 174 /** 175 * Indicates that the value type is boolean. 176 * 177 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 178 * @since 9 179 */ 180 BOOLEAN, 181 182 /** 183 * Indicates that the value type is double. 184 * 185 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 186 * @since 9 187 */ 188 DOUBLE 189 } 190 191 /** 192 * Obtains {@code Value} objects stored in a {@link SingleKVStore} or {@link DeviceKVStore} database. 193 * 194 * @interface Value 195 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 196 * @since 9 197 */ 198 interface Value { 199 /** 200 * Indicates the value type 201 * 202 * @type { ValueType } 203 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 204 * @since 9 205 * @see ValueType 206 */ 207 type: ValueType; 208 209 /** 210 * Indicates the value 211 * 212 * @type { Uint8Array | string | number | boolean } 213 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 214 * @since 9 215 */ 216 value: Uint8Array | string | number | boolean; 217 } 218 219 /** 220 * Provides key-value pairs stored in the distributedKVStore. 221 * 222 * @interface Entry 223 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 224 * @since 9 225 */ 226 interface Entry { 227 /** 228 * Indicates the key 229 * 230 * @type { string } 231 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 232 * @since 9 233 */ 234 key: string; 235 236 /** 237 * Indicates the value 238 * 239 * @type { Value } 240 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 241 * @since 9 242 */ 243 value: Value; 244 } 245 246 /** 247 * Receive notifications of all data changes, including data insertion, update, and deletion. 248 * <p>If you have subscribed to {@code SingleKVStore} or {@code DeviceKVStore}, you will receive 249 * data change notifications and obtain the changed data from the parameters in callback methods 250 * upon data insertion, update or deletion. 251 * 252 * @interface ChangeNotification 253 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 254 * @since 9 255 */ 256 interface ChangeNotification { 257 /** 258 * Indicates data insertion records. 259 * 260 * @type { Entry[] } 261 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 262 * @since 9 263 */ 264 insertEntries: Entry[]; 265 266 /** 267 * Indicates data update records. 268 * 269 * @type { Entry[] } 270 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 271 * @since 9 272 */ 273 updateEntries: Entry[]; 274 275 /** 276 * Indicates data deletion records. 277 * 278 * @type { Entry[] } 279 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 280 * @since 9 281 */ 282 deleteEntries: Entry[]; 283 284 /** 285 * Indicates the device id which brings the data change. 286 * 287 * @type { string } 288 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 289 * @since 9 290 */ 291 deviceId: string; 292 } 293 294 /** 295 * Indicates the database synchronization mode. 296 * 297 * @enum { number } 298 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 299 * @since 9 300 */ 301 enum SyncMode { 302 /** 303 * Indicates that data is only pulled from the remote end. 304 * 305 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 306 * @since 9 307 */ 308 PULL_ONLY, 309 310 /** 311 * Indicates that data is only pushed from the local end. 312 * 313 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 314 * @since 9 315 */ 316 PUSH_ONLY, 317 318 /** 319 * Indicates that data is pushed from the local end, and then pulled from the remote end. 320 * 321 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 322 * @since 9 323 */ 324 PUSH_PULL 325 } 326 327 /** 328 * Describes the subscription type. 329 * 330 * @enum { number } 331 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 332 * @since 9 333 */ 334 enum SubscribeType { 335 /** 336 * Subscription to local data changes 337 * 338 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 339 * @since 9 340 */ 341 SUBSCRIBE_TYPE_LOCAL, 342 343 /** 344 * Subscription to remote data changes 345 * 346 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 347 * @since 9 348 */ 349 SUBSCRIBE_TYPE_REMOTE, 350 351 /** 352 * Subscription to both local and remote data changes 353 * 354 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 355 * @since 9 356 */ 357 SUBSCRIBE_TYPE_ALL 358 } 359 360 /** 361 * Describes the KVStore type. 362 * 363 * @enum { number } 364 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 365 * @since 9 366 */ 367 enum KVStoreType { 368 /** 369 * Device-collaboration database, as specified by {@code DeviceKVStore} 370 * 371 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 372 * @since 9 373 */ 374 DEVICE_COLLABORATION, 375 376 /** 377 * Single-version database, as specified by {@code SingleKVStore} 378 * 379 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 380 * @since 9 381 */ 382 SINGLE_VERSION 383 } 384 385 /** 386 * Describes the KVStore security level. 387 * 388 * @enum { number } 389 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 390 * @since 9 391 */ 392 enum SecurityLevel { 393 /** 394 * S1: means the db is in the low security level 395 * There are some low impact when the data is leaked. 396 * 397 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 398 * @since 9 399 */ 400 S1, 401 402 /** 403 * S2: means the db is in the middle security level 404 * There are some major impact when the data is leaked. 405 * 406 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 407 * @since 9 408 */ 409 S2, 410 411 /** 412 * S3: means the db is in the high security level 413 * There are some severity impact when the data is leaked. 414 * 415 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 416 * @since 9 417 */ 418 S3, 419 420 /** 421 * S4: means the db is in the critical security level 422 * There are some critical impact when the data is leaked. 423 * 424 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 425 * @since 9 426 */ 427 S4 428 } 429 430 /** 431 * Provides configuration options to create a {@code SingleKVStore} or {@code DeviceKVStore}. 432 * 433 * @interface Options 434 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 435 * @since 9 436 */ 437 interface Options { 438 /** 439 * Indicates whether to create a database when the database file does not exist 440 * 441 * @type { ?boolean } 442 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 443 * @since 9 444 */ 445 createIfMissing?: boolean; 446 447 /** 448 * Indicates whether database files to be encrypted 449 * 450 * @type { ?boolean } 451 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 452 * @since 9 453 */ 454 encrypt?: boolean; 455 456 /** 457 * Indicates whether to back up database files 458 * 459 * @type { ?boolean } 460 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 461 * @since 9 462 */ 463 backup?: boolean; 464 465 /** 466 * Indicates whether database files are automatically synchronized 467 * 468 * @permission ohos.permission.DISTRIBUTED_DATASYNC 469 * @type { ?boolean } 470 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 471 * @since 9 472 */ 473 autoSync?: boolean; 474 475 /** 476 * Indicates the database type 477 * 478 * @type { ?KVStoreType } 479 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 480 * @since 9 481 */ 482 kvStoreType?: KVStoreType; 483 484 /** 485 * Indicates the database security level 486 * 487 * @type { SecurityLevel } 488 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 489 * @since 9 490 */ 491 securityLevel: SecurityLevel; 492 493 /** 494 * Indicates the database schema 495 * 496 * @type { ?Schema } 497 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 498 * @since 9 499 */ 500 schema?: Schema; 501 } 502 503 /** 504 * Represents the database schema. 505 * You can set the schema object in options when create or open the database. 506 * 507 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 508 * @since 9 509 */ 510 class Schema { 511 /** 512 * A constructor used to create a Schema instance. 513 * 514 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 515 * @since 9 516 */ 517 constructor(); 518 519 /** 520 * Indicates the root json object. 521 * 522 * @type { FieldNode } 523 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 524 * @since 9 525 */ 526 root: FieldNode; 527 528 /** 529 * Indicates the string array of json. 530 * 531 * @type { Array<string> } 532 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 533 * @since 9 534 */ 535 indexes: Array<string>; 536 537 /** 538 * Indicates the mode of schema. 539 * 540 * @type { number } 541 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 542 * @since 9 543 */ 544 mode: number; 545 546 /** 547 * Indicates the skip size of schema. 548 * 549 * @type { number } 550 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 551 * @since 9 552 */ 553 skip: number; 554 } 555 556 /** 557 * Represents a node of a {@link Schema} instance. 558 * <p>With a {@link Schema} instance, you can define the value fields which stored in the database. 559 * <p>A FieldNode of the {@link Schema} instance is either a leaf or a non-leaf node. 560 * <p>The leaf node must have a value; the non-leaf node must have a child {@code FieldNode}. 561 * 562 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 563 * @since 9 564 */ 565 class FieldNode { 566 /** 567 * A constructor used to create a FieldNode instance with the specified field. 568 * name Indicates the field node name. 569 * 570 * @param { string } name - It can not be empty. 571 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 572 * <br>2.Parameter verification failed. 573 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 574 * @since 9 575 */ 576 constructor(name: string); 577 578 /** 579 * Adds a child node to this {@code FieldNode}. 580 * <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. 581 * 582 * @param { FieldNode } child - The field node to append. 583 * @returns { boolean } Returns true if the child node is successfully added to this {@code FieldNode} and false otherwise. 584 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 585 * <br>2.Incorrect parameters types. 586 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 587 * @since 9 588 */ 589 appendChild(child: FieldNode): boolean; 590 591 /** 592 * Indicates the default value of field node. 593 * 594 * @type { string } 595 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 596 * @since 9 597 */ 598 default: string; 599 600 /** 601 * Indicates the nullable of database field. 602 * 603 * @type { boolean } 604 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 605 * @since 9 606 */ 607 nullable: boolean; 608 609 /** 610 * Indicates the type of value. 611 * 612 * @type { number } 613 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 614 * @since 9 615 */ 616 type: number; 617 } 618 619 /** 620 * Provides methods to operate the result set of the {@code SingleKVStore} or {@code DeviceKVStore} database. 621 * <p>The result set is created by using the {@code getResultSet} method in the {@code SingleKVStore} or 622 * {@code DeviceKVStore} class. This interface also provides methods to move the data read 623 * position in the result set. 624 * 625 * @interface KVStoreResultSet 626 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 627 * @since 9 628 */ 629 interface KVStoreResultSet { 630 /** 631 * Obtains the number of lines in a result set. 632 * 633 * @returns { number } Returns the number of lines. 634 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 635 * @since 9 636 */ 637 getCount(): number; 638 639 /** 640 * Obtains the current read position in a result set. 641 * 642 * @returns { number } Returns the current read position. The read position starts with 0. 643 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 644 * @since 9 645 */ 646 getPosition(): number; 647 648 /** 649 * Moves the read position to the first line. 650 * <p>If the result set is empty, false is returned. 651 * 652 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 653 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 654 * @since 9 655 */ 656 moveToFirst(): boolean; 657 658 /** 659 * Moves the read position to the last line. 660 * <p>If the result set is empty, false is returned. 661 * 662 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 663 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 664 * @since 9 665 */ 666 moveToLast(): boolean; 667 668 /** 669 * Moves the read position to the next line. 670 * <p>If the result set is empty or the data in the last line is being read, false is returned. 671 * 672 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 673 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 674 * @since 9 675 */ 676 moveToNext(): boolean; 677 678 /** 679 * Moves the read position to the previous line. 680 * <p>If the result set is empty or the data in the first line is being read, false is returned. 681 * 682 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 683 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 684 * @since 9 685 */ 686 moveToPrevious(): boolean; 687 688 /** 689 * Moves the read position by a relative offset to the current position. 690 * 691 * @param { number } offset - Indicates the relative offset to the current position. A negative offset indicates moving 692 * backwards, and a positive offset indicates moving forwards. For example, if the current position is entry 1 and 693 * this offset is 2, the destination position will be entry 3; if the current position is entry 3 and this offset is -2, 694 * the destination position will be entry 1. The valid final position after moving forwards starts with 0. If the 695 * final position is invalid, false will be returned. 696 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 697 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 698 * <br>2.Incorrect parameters types. 699 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 700 * @since 9 701 */ 702 move(offset: number): boolean; 703 704 /** 705 * Moves the read position from 0 to an absolute position. 706 * 707 * @param { number } position - Indicates the absolute position. 708 * @returns { boolean } Returns true if the operation succeeds; return false otherwise. 709 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 710 * <br>2.Incorrect parameters types. 711 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 712 * @since 9 713 */ 714 moveToPosition(position: number): boolean; 715 716 /** 717 * Checks whether the read position is the first line. 718 * 719 * @returns { boolean } Returns true if the read position is the first line; returns false otherwise. 720 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 721 * @since 9 722 */ 723 isFirst(): boolean; 724 725 /** 726 * Checks whether the read position is the last line. 727 * 728 * @returns { boolean } Returns true if the read position is the last line; returns false otherwise. 729 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 730 * @since 9 731 */ 732 isLast(): boolean; 733 734 /** 735 * Checks whether the read position is before the last line. 736 * 737 * @returns { boolean } Returns true if the read position is before the first line; returns false otherwise. 738 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 739 * @since 9 740 */ 741 isBeforeFirst(): boolean; 742 743 /** 744 * Checks whether the read position is after the last line. 745 * 746 * @returns { boolean } Returns true if the read position is after the last line; returns false otherwise. 747 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 748 * @since 9 749 */ 750 isAfterLast(): boolean; 751 752 /** 753 * Obtains a key-value pair. 754 * 755 * @returns { Entry } Returns a key-value pair. 756 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 757 * @since 9 758 */ 759 getEntry(): Entry; 760 } 761 762 /** 763 * Represents a database query using predicates. 764 * <p>This class provides a constructor used to create a {@code Query} instance, which is used to query data 765 * matching specified conditions in the database. 766 * <p>This class also provides methods to add predicates to the {@code Query} instance. 767 * 768 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 769 * @since 9 770 */ 771 class Query { 772 /** 773 * A constructor used to create a Query instance. 774 * 775 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 776 * @since 9 777 */ 778 constructor(); 779 780 /** 781 * Resets this {@code Query} object. 782 * 783 * @returns { Query } Returns the reset {@code Query} object. 784 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 785 * @since 9 786 */ 787 reset(): Query; 788 789 /** 790 * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value. 791 * 792 * @param { string } field - Indicates the field, which cannot contain ^. 793 * @param { number | string | boolean } value - Indicates the value to be compared. 794 * @returns { Query } Returns the {@coed Query} object. 795 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 796 * <br>2.Incorrect parameters types; 797 * <br>3.Parameter verification failed. 798 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 799 * @since 9 800 */ 801 equalTo(field: string, value: number | string | boolean): Query; 802 803 /** 804 * Constructs a {@code Query} object to query entries with the specified field whose value is not equal to the specified int value. 805 * 806 * @param { string } field - Indicates the field, which cannot contain ^. 807 * @param { number | string | boolean } value - Indicates the value to be compared. 808 * @returns { Query } Returns the {@coed Query} object. 809 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 810 * <br>2.Incorrect parameters types; 811 * <br>3.Parameter verification failed. 812 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 813 * @since 9 814 */ 815 notEqualTo(field: string, value: number | string | boolean): Query; 816 817 /** 818 * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or equal to the 819 * specified int value. 820 * 821 * @param { string } field - Indicates the field, which cannot contain ^. 822 * @param { number | string | boolean } value - Indicates the value to be compared. 823 * @returns { Query } Returns the {@coed Query} object. 824 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 825 * <br>2.Incorrect parameters types; 826 * <br>3.Parameter verification failed. 827 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 828 * @since 9 829 */ 830 greaterThan(field: string, value: number | string | boolean): Query; 831 832 /** 833 * Constructs a {@code Query} object to query entries with the specified field whose value is less than the specified int value. 834 * 835 * @param { string } field - Indicates the field, which cannot contain ^. 836 * @param { number | string } value - Indicates the value to be compared. 837 * @returns { Query } Returns the {@coed Query} object. 838 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 839 * <br>2.Incorrect parameters types; 840 * <br>3.Parameter verification failed. 841 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 842 * @since 9 843 */ 844 lessThan(field: string, value: number | string): Query; 845 846 /** 847 * Constructs a {@code Query} object to query entries with the specified field whose value is greater than or 848 * equal to the specified int value. 849 * 850 * @param { string } field - Indicates the field, which cannot contain ^. 851 * @param { number | string } value - Indicates the value to be compared. 852 * @returns { Query } Returns the {@coed Query} object. 853 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 854 * <br>2.Incorrect parameters types; 855 * <br>3.Parameter verification failed. 856 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 857 * @since 9 858 */ 859 greaterThanOrEqualTo(field: string, value: number | string): Query; 860 861 /** 862 * Constructs a {@code Query} object to query entries with the specified field whose value is less than or equal to the 863 * specified int value. 864 * 865 * @param { string } field - Indicates the field, which cannot contain ^. 866 * @param { number | string } value - Indicates the value to be compared. 867 * @returns { Query } Returns the {@coed Query} object. 868 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 869 * <br>2.Incorrect parameters types; 870 * <br>3.Parameter verification failed. 871 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 872 * @since 9 873 */ 874 lessThanOrEqualTo(field: string, value: number | string): Query; 875 876 /** 877 * Constructs a {@code Query} object to query entries with the specified field whose value is null. 878 * 879 * @param { string } field - Indicates the field, which cannot contain ^. 880 * @returns { Query } Returns the {@coed Query} object. 881 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 882 * <br>2.Incorrect parameters types; 883 * <br>3.Parameter verification failed. 884 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 885 * @since 9 886 */ 887 isNull(field: string): Query; 888 889 /** 890 * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified int value list. 891 * 892 * @param { string } field - Indicates the field, which cannot contain ^. 893 * @param { number[] } valueList - Indicates the int value list. 894 * @returns { Query } Returns the {@coed Query} object. 895 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 896 * <br>2.Incorrect parameters types; 897 * <br>3.Parameter verification failed. 898 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 899 * @since 9 900 */ 901 inNumber(field: string, valueList: number[]): Query; 902 903 /** 904 * Constructs a {@code Query} object to query entries with the specified field whose value is within the specified string value list. 905 * 906 * @param { string } field - Indicates the field, which cannot contain ^. 907 * @param { string[] } valueList - Indicates the string value list. 908 * @returns { Query } Returns the {@coed Query} object. 909 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 910 * <br>2.Incorrect parameters types; 911 * <br>3.Parameter verification failed. 912 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 913 * @since 9 914 */ 915 inString(field: string, valueList: string[]): Query; 916 917 /** 918 * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified int value list. 919 * 920 * @param { string } field - Indicates the field, which cannot contain ^. 921 * @param { number[] } valueList - Indicates the int value list. 922 * @returns { Query } Returns the {@coed Query} object. 923 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 924 * <br>2.Incorrect parameters types; 925 * <br>3.Parameter verification failed. 926 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 927 * @since 9 928 */ 929 notInNumber(field: string, valueList: number[]): Query; 930 931 /** 932 * Constructs a {@code Query} object to query entries with the specified field whose value is not within the specified string value list. 933 * 934 * @param { string } field - Indicates the field, which cannot contain ^. 935 * @param { string[] } valueList - Indicates the string value list. 936 * @returns { Query } Returns the {@coed Query} object. 937 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 938 * <br>2.Incorrect parameters types; 939 * <br>3.Parameter verification failed. 940 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 941 * @since 9 942 */ 943 notInString(field: string, valueList: string[]): Query; 944 945 /** 946 * Constructs a {@code Query} object to query entries with the specified field whose value is similar to the specified string value. 947 * 948 * @param { string } field - Indicates the field, which cannot contain ^. 949 * @param { string } value - Indicates the string value. 950 * @returns { Query } Returns the {@coed Query} object. 951 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 952 * <br>2.Incorrect parameters types; 953 * <br>3.Parameter verification failed. 954 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 955 * @since 9 956 */ 957 like(field: string, value: string): Query; 958 959 /** 960 * Constructs a {@code Query} object to query entries with the specified field whose value is not similar to the specified string value. 961 * 962 * @param { string } field - Indicates the field, which cannot contain ^. 963 * @param { string } value - Indicates the string value. 964 * @returns { Query } Returns the {@coed Query} object. 965 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 966 * <br>2.Incorrect parameters types; 967 * <br>3.Parameter verification failed. 968 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 969 * @since 9 970 */ 971 unlike(field: string, value: string): Query; 972 973 /** 974 * Constructs a {@code Query} object with the and condition. 975 * <p>Multiple predicates should be connected using the and or or condition. 976 * 977 * @returns { Query } Returns the {@coed Query} object. 978 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 979 * @since 9 980 */ 981 and(): Query; 982 983 /** 984 * Constructs a {@code Query} object with the or condition. 985 * <p>Multiple predicates should be connected using the and or or condition. 986 * 987 * @returns { Query } Returns the {@coed Query} object. 988 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 989 * @since 9 990 */ 991 or(): Query; 992 993 /** 994 * Constructs a {@code Query} object to sort the query results in ascending order. 995 * 996 * @param { string } field - Indicates the field, which cannot contain ^. 997 * @returns { Query } Returns the {@coed Query} object. 998 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 999 * <br>2.Incorrect parameters types; 1000 * <br>3.Parameter verification failed. 1001 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1002 * @since 9 1003 */ 1004 orderByAsc(field: string): Query; 1005 1006 /** 1007 * Constructs a {@code Query} object to sort the query results in descending order. 1008 * 1009 * @param { string } field - Indicates the field, which cannot contain ^. 1010 * @returns { Query } Returns the {@coed Query} object. 1011 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1012 * <br>2.Incorrect parameters types; 1013 * <br>3.Parameter verification failed. 1014 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1015 * @since 9 1016 */ 1017 orderByDesc(field: string): Query; 1018 1019 /** 1020 * Constructs a {@code Query} object to specify the number of results and the start position. 1021 * 1022 * @param { number } total - Indicates the number of results. 1023 * @param { number } offset - Indicates the start position. 1024 * @returns { Query } Returns the {@coed Query} object. 1025 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1026 * <br>2.Incorrect parameters types. 1027 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1028 * @since 9 1029 */ 1030 limit(total: number, offset: number): Query; 1031 1032 /** 1033 * Creates a {@code Query} condition with a specified field that is not null. 1034 * 1035 * @param { string } field - Indicates the specified field. 1036 * @returns { Query } Returns the {@coed Query} object. 1037 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1038 * <br>2.Incorrect parameters types. 1039 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1040 * @since 9 1041 */ 1042 isNotNull(field: string): Query; 1043 1044 /** 1045 * Creates a query condition group with a left bracket. 1046 * <p>Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a 1047 * whole to combine with other query conditions. 1048 * 1049 * @returns { Query } Returns the {@coed Query} object. 1050 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1051 * @since 9 1052 */ 1053 beginGroup(): Query; 1054 1055 /** 1056 * Creates a query condition group with a right bracket. 1057 * <p>Multiple query conditions in an {@code Query} object can be grouped. The query conditions in a group can be used as a 1058 * whole to combine with other query conditions. 1059 * 1060 * @returns { Query } Returns the {@coed Query} object. 1061 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1062 * @since 9 1063 */ 1064 endGroup(): Query; 1065 1066 /** 1067 * Creates a query condition with a specified key prefix. 1068 * 1069 * @param { string } prefix - Indicates the specified key prefix. 1070 * @returns { Query } Returns the {@coed Query} object. 1071 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1072 * <br>2.Incorrect parameters types. 1073 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1074 * @since 9 1075 */ 1076 prefixKey(prefix: string): Query; 1077 1078 /** 1079 * Sets a specified index that will be preferentially used for query. 1080 * 1081 * @param { string } index - Indicates the index to set. 1082 * @returns { Query } Returns the {@coed Query} object. 1083 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1084 * <br>2.Incorrect parameters types. 1085 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1086 * @since 9 1087 */ 1088 setSuggestIndex(index: string): Query; 1089 1090 /** 1091 * Add device ID key prefix.Used by {@code DeviceKVStore}. 1092 * 1093 * @param { string } deviceId - Specify device id to query from, It can not be empty. 1094 * @returns { Query } Returns the {@code Query} object with device ID prefix added. 1095 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1096 * <br>2.Incorrect parameters types; 1097 * <br>3.Parameter verification failed. 1098 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1099 * @since 9 1100 */ 1101 deviceId(deviceId: string): Query; 1102 1103 /** 1104 * Get a String that represents this {@code Query}. 1105 * <p>The String would be parsed to DB query format. 1106 * The String length should be no longer than 500kb. 1107 * 1108 * @returns { string } String representing this {@code Query}. 1109 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1110 * @since 9 1111 */ 1112 getSqlLike(): string; 1113 } 1114 1115 /** 1116 * Provides methods related to single-version distributed databases. 1117 * <p>To create a {@code SingleKVStore} database, 1118 * you can use the {@link data.distributed.common.KVManager#getKVStore(Options, String)} method 1119 * with {@code KVStoreType} set to {@code SINGLE_VERSION} for the input parameter {@code Options}. 1120 * This database synchronizes data to other databases in time sequence. 1121 * The {@code SingleKVStore} database does not support 1122 * synchronous transactions, or data search using snapshots. 1123 * 1124 * @interface SingleKVStore 1125 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1126 * @since 9 1127 */ 1128 interface SingleKVStore { 1129 /** 1130 * Writes a key-value pair of the string type into the {@code SingleKVStore} database. 1131 * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. 1132 * 1133 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1134 * Spaces before and after the key will be cleared. 1135 * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. 1136 * @param { AsyncCallback<void> } callback - the callback of put. 1137 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1138 * <br>2.Incorrect parameters types; 1139 * <br>3.Parameter verification failed. 1140 * @throws { BusinessError } 15100003 - Database corrupted. 1141 * @throws { BusinessError } 15100005 - Database or result set already closed. 1142 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1143 * @since 9 1144 */ 1145 /** 1146 * Writes a key-value pair of the string type into the {@code SingleKVStore} database. 1147 * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. 1148 * 1149 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1150 * Spaces before and after the key will be cleared. 1151 * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. 1152 * @param { AsyncCallback<void> } callback - the callback of put. 1153 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1154 * <br>2.Incorrect parameters types; 1155 * <br>3.Parameter verification failed. 1156 * @throws { BusinessError } 15100003 - Database corrupted. 1157 * @throws { BusinessError } 15100005 - Database or result set already closed. 1158 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1159 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1160 * @since 10 1161 */ 1162 put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void; 1163 1164 /** 1165 * Writes a key-value pair of the string type into the {@code SingleKVStore} database. 1166 * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. 1167 * 1168 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1169 * Spaces before and after the key will be cleared. 1170 * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. 1171 * @returns { Promise<void> } the promise returned by the function. 1172 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1173 * <br>2.Incorrect parameters types; 1174 * <br>3.Parameter verification failed. 1175 * @throws { BusinessError } 15100003 - Database corrupted. 1176 * @throws { BusinessError } 15100005 - Database or result set already closed. 1177 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1178 * @since 9 1179 */ 1180 /** 1181 * Writes a key-value pair of the string type into the {@code SingleKVStore} database. 1182 * <p>If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. 1183 * 1184 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1185 * Spaces before and after the key will be cleared. 1186 * @param { Uint8Array | string | number | boolean } value - Indicates the value to be inserted. 1187 * @returns { Promise<void> } the promise returned by the function. 1188 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1189 * <br>2.Incorrect parameters types; 1190 * <br>3.Parameter verification failed. 1191 * @throws { BusinessError } 15100003 - Database corrupted. 1192 * @throws { BusinessError } 15100005 - Database or result set already closed. 1193 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1194 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1195 * @since 10 1196 */ 1197 put(key: string, value: Uint8Array | string | number | boolean): Promise<void>; 1198 1199 /** 1200 * Inserts key-value pairs into the {@code SingleKVStore} database in batches. 1201 * 1202 * @param { Entry[] } entries - Indicates the key-value pairs to be inserted in batches. 1203 * @param { AsyncCallback<void> } callback - the callback of putBatch. 1204 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1205 * <br>2.Incorrect parameters types. 1206 * @throws { BusinessError } 15100003 - Database corrupted. 1207 * @throws { BusinessError } 15100005 - Database or result set already closed. 1208 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1209 * @since 9 1210 */ 1211 /** 1212 * Inserts key-value pairs into the {@code SingleKVStore} database in batches. 1213 * 1214 * @param { Entry[] } entries - Indicates the key-value pairs to be inserted in batches. 1215 * @param { AsyncCallback<void> } callback - the callback of putBatch. 1216 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1217 * <br>2.Incorrect parameters types. 1218 * @throws { BusinessError } 15100003 - Database corrupted. 1219 * @throws { BusinessError } 15100005 - Database or result set already closed. 1220 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1221 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1222 * @since 10 1223 */ 1224 putBatch(entries: Entry[], callback: AsyncCallback<void>): void; 1225 1226 /** 1227 * Inserts key-value pairs into the {@code SingleKVStore} database in batches. 1228 * 1229 * @param { Entry[] } entries - Indicates the key-value pairs to be inserted in batches. 1230 * @returns { Promise<void> } the promise returned by the function. 1231 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1232 * <br>2.Incorrect parameters types. 1233 * @throws { BusinessError } 15100003 - Database corrupted. 1234 * @throws { BusinessError } 15100005 - Database or result set already closed. 1235 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1236 * @since 9 1237 */ 1238 /** 1239 * Inserts key-value pairs into the {@code SingleKVStore} database in batches. 1240 * 1241 * @param { Entry[] } entries - Indicates the key-value pairs to be inserted in batches. 1242 * @returns { Promise<void> } the promise returned by the function. 1243 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1244 * <br>2.Incorrect parameters types. 1245 * @throws { BusinessError } 15100003 - Database corrupted. 1246 * @throws { BusinessError } 15100005 - Database or result set already closed. 1247 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1248 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1249 * @since 10 1250 */ 1251 putBatch(entries: Entry[]): Promise<void>; 1252 1253 /** 1254 * Writes values of ValuesBucket type into the {@code SingleKVStore} database. 1255 * 1256 * @param { Array<ValuesBucket> } value - Indicates the ValuesBucket array to be inserted. 1257 * @param { AsyncCallback<void> } callback - the callback of putBatch. 1258 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1259 * <br>2.Incorrect parameters types. 1260 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1261 * @throws { BusinessError } 15100003 - Database corrupted. 1262 * @throws { BusinessError } 15100005 - Database or result set already closed. 1263 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1264 * @systemapi 1265 * @StageModelOnly 1266 * @since 9 1267 */ 1268 /** 1269 * Writes values of ValuesBucket type into the {@code SingleKVStore} database. 1270 * 1271 * @param { Array<ValuesBucket> } value - Indicates the ValuesBucket array to be inserted. 1272 * @param { AsyncCallback<void> } callback - the callback of putBatch. 1273 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1274 * <br>2.Incorrect parameters types. 1275 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1276 * @throws { BusinessError } 15100003 - Database corrupted. 1277 * @throws { BusinessError } 15100005 - Database or result set already closed. 1278 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1279 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1280 * @systemapi 1281 * @StageModelOnly 1282 * @since 10 1283 */ 1284 putBatch(value: Array<ValuesBucket>, callback: AsyncCallback<void>): void; 1285 1286 /** 1287 * Writes values of ValuesBucket type into the {@code SingleKVStore} database. 1288 * 1289 * @param { Array<ValuesBucket> } value - Indicates the ValuesBucket array to be inserted. 1290 * @returns { Promise<void> } the promise returned by the function. 1291 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1292 * <br>2.Incorrect parameters types. 1293 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1294 * @throws { BusinessError } 15100003 - Database corrupted. 1295 * @throws { BusinessError } 15100005 - Database or result set already closed. 1296 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1297 * @systemapi 1298 * @StageModelOnly 1299 * @since 9 1300 */ 1301 /** 1302 * Writes values of ValuesBucket type into the {@code SingleKVStore} database. 1303 * 1304 * @param { Array<ValuesBucket> } value - Indicates the ValuesBucket array to be inserted. 1305 * @returns { Promise<void> } the promise returned by the function. 1306 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1307 * <br>2.Incorrect parameters types. 1308 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1309 * @throws { BusinessError } 15100003 - Database corrupted. 1310 * @throws { BusinessError } 15100005 - Database or result set already closed. 1311 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1312 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1313 * @systemapi 1314 * @StageModelOnly 1315 * @since 10 1316 */ 1317 putBatch(value: Array<ValuesBucket>): Promise<void>; 1318 1319 /** 1320 * Deletes the key-value pair based on a specified key. 1321 * 1322 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1323 * Spaces before and after the key will be cleared. 1324 * @param { AsyncCallback<void> } callback - the callback of delete. 1325 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1326 * <br>2.Incorrect parameters types; 1327 * <br>3.Parameter verification failed. 1328 * @throws { BusinessError } 15100003 - Database corrupted. 1329 * @throws { BusinessError } 15100005 - Database or result set already closed. 1330 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1331 * @since 9 1332 */ 1333 /** 1334 * Deletes the key-value pair based on a specified key. 1335 * 1336 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1337 * Spaces before and after the key will be cleared. 1338 * @param { AsyncCallback<void> } callback - the callback of delete. 1339 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1340 * <br>2.Incorrect parameters types; 1341 * <br>3.Parameter verification failed. 1342 * @throws { BusinessError } 15100003 - Database corrupted. 1343 * @throws { BusinessError } 15100005 - Database or result set already closed. 1344 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1345 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1346 * @since 10 1347 */ 1348 delete(key: string, callback: AsyncCallback<void>): void; 1349 1350 /** 1351 * Deletes the key-value pair based on a specified key. 1352 * 1353 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1354 * Spaces before and after the key will be cleared. 1355 * @returns { Promise<void> } the promise returned by the function. 1356 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1357 * <br>2.Incorrect parameters types; 1358 * <br>3.Parameter verification failed. 1359 * @throws { BusinessError } 15100003 - Database corrupted. 1360 * @throws { BusinessError } 15100005 - Database or result set already closed. 1361 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1362 * @since 9 1363 */ 1364 /** 1365 * Deletes the key-value pair based on a specified key. 1366 * 1367 * @param { string } key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. 1368 * Spaces before and after the key will be cleared. 1369 * @returns { Promise<void> } the promise returned by the function. 1370 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1371 * <br>2.Incorrect parameters types; 1372 * <br>3.Parameter verification failed. 1373 * @throws { BusinessError } 15100003 - Database corrupted. 1374 * @throws { BusinessError } 15100005 - Database or result set already closed. 1375 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1376 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1377 * @since 10 1378 */ 1379 delete(key: string): Promise<void>; 1380 1381 /** 1382 * Deletes the key-value pairs based on the dataSharePredicates. 1383 * 1384 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 1385 * @param { AsyncCallback<void> } callback - the callback of delete. 1386 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1387 * <br>2.Incorrect parameters types. 1388 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1389 * @throws { BusinessError } 15100003 - Database corrupted. 1390 * @throws { BusinessError } 15100005 - Database or result set already closed. 1391 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1392 * @systemapi 1393 * @StageModelOnly 1394 * @since 9 1395 */ 1396 /** 1397 * Deletes the key-value pairs based on the dataSharePredicates. 1398 * 1399 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 1400 * @param { AsyncCallback<void> } callback - the callback of delete. 1401 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1402 * <br>2.Incorrect parameters types. 1403 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1404 * @throws { BusinessError } 15100003 - Database corrupted. 1405 * @throws { BusinessError } 15100005 - Database or result set already closed. 1406 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1407 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1408 * @systemapi 1409 * @StageModelOnly 1410 * @since 10 1411 */ 1412 delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<void>); 1413 1414 /** 1415 * Deletes the key-value pairs based on the dataSharePredicates. 1416 * 1417 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 1418 * @returns { Promise<void> } the promise returned by the function. 1419 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1420 * <br>2.Incorrect parameters types. 1421 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1422 * @throws { BusinessError } 15100003 - Database corrupted. 1423 * @throws { BusinessError } 15100005 - Database or result set already closed. 1424 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1425 * @systemapi 1426 * @StageModelOnly 1427 * @since 9 1428 */ 1429 /** 1430 * Deletes the key-value pairs based on the dataSharePredicates. 1431 * 1432 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 1433 * @returns { Promise<void> } the promise returned by the function. 1434 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1435 * <br>2.Incorrect parameters types. 1436 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1437 * @throws { BusinessError } 15100003 - Database corrupted. 1438 * @throws { BusinessError } 15100005 - Database or result set already closed. 1439 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1440 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1441 * @systemapi 1442 * @StageModelOnly 1443 * @since 10 1444 */ 1445 delete(predicates: dataSharePredicates.DataSharePredicates): Promise<void>; 1446 1447 /** 1448 * Deletes key-value pairs in batches from the {@code SingleKVStore} database. 1449 * 1450 * @param { string[] } keys - Indicates the key-value pairs to be deleted in batches, It can not be empty. 1451 * @param { AsyncCallback<void> } callback - the callback of deleteBatch. 1452 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1453 * <br>2.Incorrect parameters types; 1454 * <br>3.Parameter verification failed. 1455 * @throws { BusinessError } 15100003 - Database corrupted. 1456 * @throws { BusinessError } 15100005 - Database or result set already closed. 1457 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1458 * @since 9 1459 */ 1460 /** 1461 * Deletes key-value pairs in batches from the {@code SingleKVStore} database. 1462 * 1463 * @param { string[] } keys - Indicates the key-value pairs to be deleted in batches, It can not be empty. 1464 * @param { AsyncCallback<void> } callback - the callback of deleteBatch. 1465 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1466 * <br>2.Incorrect parameters types; 1467 * <br>3.Parameter verification failed. 1468 * @throws { BusinessError } 15100003 - Database corrupted. 1469 * @throws { BusinessError } 15100005 - Database or result set already closed. 1470 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1471 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1472 * @since 10 1473 */ 1474 deleteBatch(keys: string[], callback: AsyncCallback<void>): void; 1475 1476 /** 1477 * Deletes key-value pairs in batches from the {@code SingleKVStore} database. 1478 * 1479 * @param { string[] } keys - Indicates the key-value pairs to be deleted in batches, It can not be empty. 1480 * @returns { Promise<void> } the promise returned by the function. 1481 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1482 * <br>2.Incorrect parameters types; 1483 * <br>3.Parameter verification failed. 1484 * @throws { BusinessError } 15100003 - Database corrupted. 1485 * @throws { BusinessError } 15100005 - Database or result set already closed. 1486 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1487 * @since 9 1488 */ 1489 /** 1490 * Deletes key-value pairs in batches from the {@code SingleKVStore} database. 1491 * 1492 * @param { string[] } keys - Indicates the key-value pairs to be deleted in batches, It can not be empty. 1493 * @returns { Promise<void> } the promise returned by the function. 1494 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1495 * <br>2.Incorrect parameters types; 1496 * <br>3.Parameter verification failed. 1497 * @throws { BusinessError } 15100003 - Database corrupted. 1498 * @throws { BusinessError } 15100005 - Database or result set already closed. 1499 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1500 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1501 * @since 10 1502 */ 1503 deleteBatch(keys: string[]): Promise<void>; 1504 1505 /** 1506 * Removes data of the specified device from current database. This method is used to remove only the data 1507 * synchronized from remote devices. This operation does not synchronize data to other databases or affect 1508 * subsequent data synchronization. 1509 * 1510 * @param { string } deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. 1511 * @param { AsyncCallback<void> } callback - the callback of removeDeviceData. 1512 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1513 * <br>2.Parameter verification failed. 1514 * @throws { BusinessError } 15100005 - Database or result set already closed. 1515 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 1516 * @since 9 1517 */ 1518 removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void; 1519 1520 /** 1521 * Removes data of the specified device from current database. This method is used to remove only the data 1522 * synchronized from remote devices. This operation does not synchronize data to other databases or affect 1523 * subsequent data synchronization. 1524 * 1525 * @param { string } deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. 1526 * @returns { Promise<void> } the promise returned by the function. 1527 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1528 * <br>2.Parameter verification failed. 1529 * @throws { BusinessError } 15100005 - Database or result set already closed. 1530 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 1531 * @since 9 1532 */ 1533 removeDeviceData(deviceId: string): Promise<void>; 1534 1535 /** 1536 * Obtains the value of a specified key. 1537 * 1538 * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. 1539 * @param { AsyncCallback<boolean | string | number | Uint8Array> } callback - 1540 * {Uint8Array|string|boolean|number}: the returned value specified by the key. 1541 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1542 * <br>2.Incorrect parameters types; 1543 * <br>3.Parameter verification failed. 1544 * @throws { BusinessError } 15100003 - Database corrupted. 1545 * @throws { BusinessError } 15100004 - Not found. 1546 * @throws { BusinessError } 15100005 - Database or result set already closed. 1547 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1548 * @since 9 1549 */ 1550 get(key: string, callback: AsyncCallback<boolean | string | number | Uint8Array>): void; 1551 1552 /** 1553 * Obtains the value of a specified key. 1554 * 1555 * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. 1556 * @returns { Promise<boolean | string | number | Uint8Array> } 1557 * {Uint8Array|string|boolean|number}: the returned value specified by the key. 1558 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1559 * <br>2.Incorrect parameters types; 1560 * <br>3.Parameter verification failed. 1561 * @throws { BusinessError } 15100003 - Database corrupted. 1562 * @throws { BusinessError } 15100004 - Not found. 1563 * @throws { BusinessError } 15100005 - Database or result set already closed. 1564 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1565 * @since 9 1566 */ 1567 get(key: string): Promise<boolean | string | number | Uint8Array>; 1568 1569 /** 1570 * Obtains all key-value pairs that match a specified key prefix. 1571 * 1572 * @param { string } keyPrefix - Indicates the key prefix to match. 1573 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 1574 * that match the specified key prefix. 1575 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1576 * <br>2.Incorrect parameters types. 1577 * @throws { BusinessError } 15100003 - Database corrupted. 1578 * @throws { BusinessError } 15100005 - Database or result set already closed. 1579 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1580 * @since 9 1581 */ 1582 getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void; 1583 1584 /** 1585 * Obtains all key-value pairs that match a specified key prefix. 1586 * 1587 * @param { string } keyPrefix - Indicates the key prefix to match. 1588 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs that match the 1589 * specified key prefix. 1590 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1591 * <br>2.Incorrect parameters types. 1592 * @throws { BusinessError } 15100003 - Database corrupted. 1593 * @throws { BusinessError } 15100005 - Database or result set already closed. 1594 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1595 * @since 9 1596 */ 1597 getEntries(keyPrefix: string): Promise<Entry[]>; 1598 1599 /** 1600 * Obtains the list of key-value pairs matching the specified {@code Query} object. 1601 * 1602 * @param { Query } query - Indicates the {@code Query} object. 1603 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 1604 * matching the specified {@code Query} object. 1605 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1606 * <br>2.Incorrect parameters types. 1607 * @throws { BusinessError } 15100003 - Database corrupted. 1608 * @throws { BusinessError } 15100005 - Database or result set already closed. 1609 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1610 * @since 9 1611 */ 1612 getEntries(query: Query, callback: AsyncCallback<Entry[]>): void; 1613 1614 /** 1615 * Obtains the list of key-value pairs matching the specified {@code Query} object. 1616 * 1617 * @param { Query } query - Indicates the {@code Query} object. 1618 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs matching the 1619 * specified {@code Query} object. 1620 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1621 * <br>2.Incorrect parameters types. 1622 * @throws { BusinessError } 15100003 - Database corrupted. 1623 * @throws { BusinessError } 15100005 - Database or result set already closed. 1624 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1625 * @since 9 1626 */ 1627 getEntries(query: Query): Promise<Entry[]>; 1628 1629 /** 1630 * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} 1631 * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} 1632 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created 1633 * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet 1634 * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 1635 * 1636 * @param { string } keyPrefix - Indicates the key prefix to match. 1637 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1638 * object matching the specified keyPrefix. 1639 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1640 * <br>2.Incorrect parameters types. 1641 * @throws { BusinessError } 15100003 - Database corrupted. 1642 * @throws { BusinessError } 15100005 - Database or result set already closed. 1643 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1644 * @since 9 1645 */ 1646 /** 1647 * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} 1648 * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} 1649 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created 1650 * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet 1651 * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 1652 * 1653 * @param { string } keyPrefix - Indicates the key prefix to match. 1654 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1655 * object matching the specified keyPrefix. 1656 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1657 * <br>2.Incorrect parameters types. 1658 * @throws { BusinessError } 15100001 - Over max limits. 1659 * @throws { BusinessError } 15100003 - Database corrupted. 1660 * @throws { BusinessError } 15100005 - Database or result set already closed. 1661 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1662 * @since 10 1663 */ 1664 getResultSet(keyPrefix: string, callback: AsyncCallback<KVStoreResultSet>): void; 1665 1666 /** 1667 * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} 1668 * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} 1669 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created 1670 * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet 1671 * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 1672 * 1673 * @param { string } keyPrefix - Indicates the key prefix to match. 1674 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1675 * object matching the specified keyPrefix. 1676 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1677 * <br>2.Incorrect parameters types. 1678 * @throws { BusinessError } 15100003 - Database corrupted. 1679 * @throws { BusinessError } 15100005 - Database or result set already closed. 1680 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1681 * @since 9 1682 */ 1683 /** 1684 * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} 1685 * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} 1686 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created 1687 * four objects, calling this method will return a failure. Therefore, you are advised to call the closeResultSet 1688 * method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 1689 * 1690 * @param { string } keyPrefix - Indicates the key prefix to match. 1691 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1692 * object matching the specified keyPrefix. 1693 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1694 * <br>2.Incorrect parameters types. 1695 * @throws { BusinessError } 15100001 - Over max limits. 1696 * @throws { BusinessError } 15100003 - Database corrupted. 1697 * @throws { BusinessError } 15100005 - Database or result set already closed. 1698 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1699 * @since 10 1700 */ 1701 getResultSet(keyPrefix: string): Promise<KVStoreResultSet>; 1702 1703 /** 1704 * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. 1705 * 1706 * @param { Query } query - Indicates the {@code Query} object. 1707 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1708 * object matching the specified {@code Query} object. 1709 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1710 * <br>2.Incorrect parameters types. 1711 * @throws { BusinessError } 15100003 - Database corrupted. 1712 * @throws { BusinessError } 15100005 - Database or result set already closed. 1713 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1714 * @since 9 1715 */ 1716 /** 1717 * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. 1718 * 1719 * @param { Query } query - Indicates the {@code Query} object. 1720 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1721 * object matching the specified {@code Query} object. 1722 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1723 * <br>2.Incorrect parameters types. 1724 * @throws { BusinessError } 15100001 - Over max limits. 1725 * @throws { BusinessError } 15100003 - Database corrupted. 1726 * @throws { BusinessError } 15100005 - Database or result set already closed. 1727 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1728 * @since 10 1729 */ 1730 getResultSet(query: Query, callback: AsyncCallback<KVStoreResultSet>): void; 1731 1732 /** 1733 * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. 1734 * 1735 * @param { Query } query - Indicates the {@code Query} object. 1736 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1737 * object matching the specified {@code Query} object. 1738 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1739 * <br>2.Incorrect parameters types. 1740 * @throws { BusinessError } 15100003 - Database corrupted. 1741 * @throws { BusinessError } 15100005 - Database or result set already closed. 1742 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1743 * @since 9 1744 */ 1745 /** 1746 * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. 1747 * 1748 * @param { Query } query - Indicates the {@code Query} object. 1749 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1750 * object matching the specified {@code Query} object. 1751 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1752 * <br>2.Incorrect parameters types. 1753 * @throws { BusinessError } 15100001 - Over max limits. 1754 * @throws { BusinessError } 15100003 - Database corrupted. 1755 * @throws { BusinessError } 15100005 - Database or result set already closed. 1756 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1757 * @since 10 1758 */ 1759 getResultSet(query: Query): Promise<KVStoreResultSet>; 1760 1761 /** 1762 * Obtains the KVStoreResultSet object matching the specified predicate object. 1763 * 1764 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 1765 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1766 * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. 1767 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1768 * <br>2.Incorrect parameters types. 1769 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1770 * @throws { BusinessError } 15100003 - Database corrupted. 1771 * @throws { BusinessError } 15100005 - Database or result set already closed. 1772 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1773 * @systemapi 1774 * @StageModelOnly 1775 * @since 9 1776 */ 1777 /** 1778 * Obtains the KVStoreResultSet object matching the specified predicate object. 1779 * 1780 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 1781 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 1782 * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. 1783 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1784 * <br>2.Incorrect parameters types. 1785 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1786 * @throws { BusinessError } 15100001 - Over max limits. 1787 * @throws { BusinessError } 15100003 - Database corrupted. 1788 * @throws { BusinessError } 15100005 - Database or result set already closed. 1789 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1790 * @systemapi 1791 * @StageModelOnly 1792 * @since 10 1793 */ 1794 getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<KVStoreResultSet>): void; 1795 1796 /** 1797 * Obtains the KVStoreResultSet object matching the specified predicate object. 1798 * 1799 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 1800 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1801 * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. 1802 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1803 * <br>2.Incorrect parameters types. 1804 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1805 * @throws { BusinessError } 15100003 - Database corrupted. 1806 * @throws { BusinessError } 15100005 - Database or result set already closed. 1807 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1808 * @systemapi 1809 * @StageModelOnly 1810 * @since 9 1811 */ 1812 /** 1813 * Obtains the KVStoreResultSet object matching the specified predicate object. 1814 * 1815 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 1816 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 1817 * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. 1818 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1819 * <br>2.Incorrect parameters types. 1820 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1821 * @throws { BusinessError } 15100001 - Over max limits. 1822 * @throws { BusinessError } 15100003 - Database corrupted. 1823 * @throws { BusinessError } 15100005 - Database or result set already closed. 1824 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 1825 * @systemapi 1826 * @StageModelOnly 1827 * @since 10 1828 */ 1829 getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<KVStoreResultSet>; 1830 1831 /** 1832 * Closes a {@code KVStoreResultSet} object returned by getResultSet method. 1833 * 1834 * @param { KVStoreResultSet } resultSet - Indicates the {@code KVStoreResultSet} object to close. 1835 * @param { AsyncCallback<void> } callback - the callback of closeResultSet. 1836 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1837 * <br>2.Incorrect parameters types. 1838 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1839 * @since 9 1840 */ 1841 closeResultSet(resultSet: KVStoreResultSet, callback: AsyncCallback<void>): void; 1842 1843 /** 1844 * Closes a {@code KVStoreResultSet} object returned by getResultSet method. 1845 * 1846 * @param { KVStoreResultSet } resultSet - Indicates the {@code KVStoreResultSet} object to close. 1847 * @returns { Promise<void> } the promise returned by the function. 1848 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1849 * <br>2.Incorrect parameters types. 1850 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1851 * @since 9 1852 */ 1853 closeResultSet(resultSet: KVStoreResultSet): Promise<void>; 1854 1855 /** 1856 * Obtains the number of results matching the specified {@code Query} object. 1857 * 1858 * @param { Query } query - Indicates the {@code Query} object. 1859 * @param { AsyncCallback<number> } callback - {number}: the number of results matching the 1860 * specified {@code Query} object. 1861 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1862 * <br>2.Incorrect parameters types. 1863 * @throws { BusinessError } 15100003 - Database corrupted. 1864 * @throws { BusinessError } 15100005 - Database or result set already closed. 1865 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1866 * @since 9 1867 */ 1868 getResultSize(query: Query, callback: AsyncCallback<number>): void; 1869 1870 /** 1871 * Obtains the number of results matching the specified {@code Query} object. 1872 * 1873 * @param { Query } query - Indicates the {@code Query} object. 1874 * @returns { Promise<number> } {number}: the number of results matching the specified 1875 * {@code Query} object. 1876 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1877 * <br>2.Incorrect parameters types. 1878 * @throws { BusinessError } 15100003 - Database corrupted. 1879 * @throws { BusinessError } 15100005 - Database or result set already closed. 1880 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1881 * @since 9 1882 */ 1883 getResultSize(query: Query): Promise<number>; 1884 1885 /** 1886 * Backs up a database in the specified filename. 1887 * 1888 * @param { string } file - Indicates the database backup filename, It can not be empty and 1889 * The length must be less than {@code MAX_KEY_LENGTH}. 1890 * @param { AsyncCallback<void> } callback - the callback of backup. 1891 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1892 * <br>2.Parameter verification failed. 1893 * @throws { BusinessError } 15100005 - Database or result set already closed. 1894 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1895 * @since 9 1896 */ 1897 backup(file: string, callback: AsyncCallback<void>): void; 1898 1899 /** 1900 * Backs up a database in the specified filename. 1901 * 1902 * @param { string } file - Indicates the database backup filename, It can not be empty and 1903 * The length must be less than {@code MAX_KEY_LENGTH}. 1904 * @returns { Promise<void> } the promise returned by the function. 1905 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1906 * <br>2.Parameter verification failed. 1907 * @throws { BusinessError } 15100005 - Database or result set already closed. 1908 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1909 * @since 9 1910 */ 1911 backup(file: string): Promise<void>; 1912 1913 /** 1914 * Restores a database from a specified database file. 1915 * 1916 * @param { string } file - Indicates the database backup filename, It can not be empty and 1917 * The length must be less than {@code MAX_KEY_LENGTH}. 1918 * @param { AsyncCallback<void> } callback - the callback of restore. 1919 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1920 * <br>2.Parameter verification failed. 1921 * @throws { BusinessError } 15100005 - Database or result set already closed. 1922 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1923 * @since 9 1924 */ 1925 restore(file: string, callback: AsyncCallback<void>): void; 1926 1927 /** 1928 * Restores a database from a specified database file. 1929 * 1930 * @param { string } file - Indicates the database backup filename, It can not be empty and 1931 * The length must be less than {@code MAX_KEY_LENGTH}. 1932 * @returns { Promise<void> } the promise returned by the function. 1933 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1934 * <br>2.Parameter verification failed. 1935 * @throws { BusinessError } 15100005 - Database or result set already closed. 1936 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1937 * @since 9 1938 */ 1939 restore(file: string): Promise<void>; 1940 1941 /** 1942 * Delete database backup files based on the specified filenames. 1943 * 1944 * @param { Array<string> } files - Indicates the backup filenames to be deleted, It can not be empty and 1945 * The length must be less than {@code MAX_KEY_LENGTH}. 1946 * @param { AsyncCallback<Array<[string, number]>> } callback - {Array<[string, number]>}: 1947 * the list of backup file and it's corresponding delete result which 0 means delete success 1948 * and otherwise failed. 1949 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1950 * <br>2.Parameter verification failed. 1951 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1952 * @since 9 1953 */ 1954 deleteBackup(files: Array<string>, callback: AsyncCallback<Array<[string, number]>>): void; 1955 1956 /** 1957 * Delete database backup files based on the specified filenames. 1958 * 1959 * @param { Array<string> } files - Indicates the backup filenames to be deleted, It can not be empty and 1960 * The length must be less than {@code MAX_KEY_LENGTH}. 1961 * @returns { Promise<Array<[string, number]>> } {Array<[string, number]>}: the list of backup 1962 * file and it's corresponding delete result which 0 means delete success and otherwise failed. 1963 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1964 * <br>2.Parameter verification failed. 1965 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1966 * @since 9 1967 */ 1968 deleteBackup(files: Array<string>): Promise<Array<[string, number]>>; 1969 1970 /** 1971 * Starts a transaction operation in the {@code SingleKVStore} database. 1972 * <p>After the database transaction is started, you can submit or roll back the operation. 1973 * 1974 * @param { AsyncCallback<void> } callback - the callback of startTransaction. 1975 * @throws { BusinessError } 15100005 - Database or result set already closed. 1976 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1977 * @since 9 1978 */ 1979 /** 1980 * Starts a transaction operation in the {@code SingleKVStore} database. 1981 * <p>After the database transaction is started, you can submit or roll back the operation. 1982 * 1983 * @param { AsyncCallback<void> } callback - the callback of startTransaction. 1984 * @throws { BusinessError } 15100005 - Database or result set already closed. 1985 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 1986 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1987 * @since 10 1988 */ 1989 startTransaction(callback: AsyncCallback<void>): void; 1990 1991 /** 1992 * Starts a transaction operation in the {@code SingleKVStore} database. 1993 * <p>After the database transaction is started, you can submit or roll back the operation. 1994 * 1995 * @returns { Promise<void> } the promise returned by the function. 1996 * @throws { BusinessError } 15100005 - Database or result set already closed. 1997 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 1998 * @since 9 1999 */ 2000 /** 2001 * Starts a transaction operation in the {@code SingleKVStore} database. 2002 * <p>After the database transaction is started, you can submit or roll back the operation. 2003 * 2004 * @returns { Promise<void> } the promise returned by the function. 2005 * @throws { BusinessError } 15100005 - Database or result set already closed. 2006 * @throws { BusinessError } 14800047 - The WAL file size exceeds the default limit. 2007 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2008 * @since 10 2009 */ 2010 startTransaction(): Promise<void>; 2011 2012 /** 2013 * Submits a transaction operation in the {@code SingleKVStore} database. 2014 * 2015 * @param { AsyncCallback<void> } callback - the callback of commit. 2016 * @throws { BusinessError } 15100005 - Database or result set already closed. 2017 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2018 * @since 9 2019 */ 2020 commit(callback: AsyncCallback<void>): void; 2021 2022 /** 2023 * Submits a transaction operation in the {@code SingleKVStore} database. 2024 * 2025 * @returns { Promise<void> } the promise returned by the function. 2026 * @throws { BusinessError } 15100005 - Database or result set already closed. 2027 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2028 * @since 9 2029 */ 2030 commit(): Promise<void>; 2031 2032 /** 2033 * Rolls back a transaction operation in the {@code SingleKVStore} database. 2034 * 2035 * @param { AsyncCallback<void> } callback - the callback of rollback. 2036 * @throws { BusinessError } 15100005 - Database or result set already closed. 2037 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2038 * @since 9 2039 */ 2040 rollback(callback: AsyncCallback<void>): void; 2041 2042 /** 2043 * Rolls back a transaction operation in the {@code SingleKVStore} database. 2044 * 2045 * @returns { Promise<void> } the promise returned by the function. 2046 * @throws { BusinessError } 15100005 - Database or result set already closed. 2047 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2048 * @since 9 2049 */ 2050 rollback(): Promise<void>; 2051 2052 /** 2053 * Sets whether to enable synchronization. 2054 * 2055 * @param { boolean } enabled - Specifies whether to enable synchronization. The value true 2056 * means to enable synchronization, and false means the opposite. 2057 * @param { AsyncCallback<void> } callback - the callback of enableSync. 2058 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2059 * <br>2.Incorrect parameters types. 2060 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2061 * @since 9 2062 */ 2063 enableSync(enabled: boolean, callback: AsyncCallback<void>): void; 2064 2065 /** 2066 * Sets whether to enable synchronization. 2067 * 2068 * @param { boolean } enabled - Specifies whether to enable synchronization. The value true 2069 * means to enable synchronization, and false means the opposite. 2070 * @returns { Promise<void> } the promise returned by the function. 2071 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2072 * <br>2.Incorrect parameters types. 2073 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2074 * @since 9 2075 */ 2076 enableSync(enabled: boolean): Promise<void>; 2077 2078 /** 2079 * Sets synchronization range labels. 2080 * <p>The labels determine the devices with which data will be synchronized. 2081 * 2082 * @param { string[] } localLabels - Indicates the synchronization labels of the local device. 2083 * @param { string[] } remoteSupportLabels - Indicates the labels of the devices with which 2084 * data will be synchronized. 2085 * @param { AsyncCallback<void> } callback - the callback of setSyncRange. 2086 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2087 * <br>2.Incorrect parameters types. 2088 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2089 * @since 9 2090 */ 2091 setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback<void>): void; 2092 2093 /** 2094 * Sets synchronization range labels. 2095 * <p>The labels determine the devices with which data will be synchronized. 2096 * 2097 * @param { string[] } localLabels - Indicates the synchronization labels of the local device. 2098 * @param { string[] } remoteSupportLabels - Indicates the labels of the devices with which 2099 * data will be synchronized. 2100 * @returns { Promise<void> } the promise returned by the function. 2101 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2102 * <br>2.Incorrect parameters types. 2103 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2104 * @since 9 2105 */ 2106 setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<void>; 2107 2108 /** 2109 * Sets the default delay allowed for database synchronization 2110 * 2111 * @param { number } defaultAllowedDelayMs - Indicates the default delay allowed for the 2112 * database synchronization, in milliseconds. 2113 * @param { AsyncCallback<void> } callback - the callback of setSyncParam. 2114 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2115 * <br>2.Incorrect parameters types. 2116 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2117 * @since 9 2118 */ 2119 setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void; 2120 2121 /** 2122 * Sets the default delay allowed for database synchronization 2123 * 2124 * @param { number } defaultAllowedDelayMs - Indicates the default delay allowed for the 2125 * database synchronization, in milliseconds. 2126 * @returns { Promise<void> } the promise returned by the function. 2127 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2128 * <br>2.Incorrect parameters types. 2129 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2130 * @since 9 2131 */ 2132 setSyncParam(defaultAllowedDelayMs: number): Promise<void>; 2133 2134 /** 2135 * Synchronize the database to the specified devices with the specified delay allowed. 2136 * 2137 * @permission ohos.permission.DISTRIBUTED_DATASYNC 2138 * @param { string[] } deviceIds - Indicates the list of devices to which to synchronize the database. 2139 * @param { SyncMode } mode - Indicates the synchronization mode. The value can be {@code PUSH}, 2140 * {@code PULL}, or {@code PUSH_PULL}. 2141 * @param { number } delayMs - Indicates the delay allowed for the synchronization, in milliseconds. 2142 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2143 * <br>2.Incorrect parameters types. 2144 * @throws { BusinessError } 15100003 - Database corrupted. 2145 * @throws { BusinessError } 15100004 - Not found. 2146 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2147 * @since 9 2148 */ 2149 sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; 2150 2151 /** 2152 * Synchronize the database to the specified devices with the specified delay allowed. 2153 * 2154 * @permission ohos.permission.DISTRIBUTED_DATASYNC 2155 * @param { string[] } deviceIds - Indicates the list of devices to which to synchronize the database. 2156 * @param { Query } query - Indicates the {@code Query} object. 2157 * @param { SyncMode } mode - Indicates the synchronization mode. The value can be {@code PUSH}, 2158 * {@code PULL}, or {@code PUSH_PULL}. 2159 * @param { number } delayMs - Indicates the delay allowed for the synchronization, in milliseconds. 2160 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2161 * <br>2.Incorrect parameters types. 2162 * @throws { BusinessError } 15100003 - Database corrupted. 2163 * @throws { BusinessError } 15100004 - Not found. 2164 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2165 * @since 9 2166 */ 2167 sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; 2168 2169 /** 2170 * Register a callback to the database and when data in the distributed database has changed, 2171 * the callback will be invoked. 2172 * 2173 * @param { 'dataChange' } event - Subscribed event name, fixed as 'dataChange', indicates the data change event. 2174 * @param { SubscribeType } type - Indicates the subscription type, which is defined in {@code SubscribeType}. 2175 * @param { Callback<ChangeNotification> } listener - {ChangeNotification}: the {@code ChangeNotification} 2176 * object indicates the data change events in the distributed database. 2177 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2178 * <br>2.Incorrect parameters types. 2179 * @throws { BusinessError } 15100001 - Over max limits. 2180 * @throws { BusinessError } 15100005 - Database or result set already closed. 2181 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2182 * @since 9 2183 */ 2184 /** 2185 * Register a callback to the database and when data in the distributed database has changed, 2186 * the callback will be invoked. 2187 * 2188 * @param { 'dataChange' } event - Subscribed event name, fixed as 'dataChange', indicates the data change event. 2189 * @param { SubscribeType } type - Indicates the subscription type, which is defined in {@code SubscribeType}. 2190 * @param { Callback<ChangeNotification> } listener - {ChangeNotification}: the {@code ChangeNotification} 2191 * object indicates the data change events in the distributed database. 2192 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2193 * <br>2.Incorrect parameters types. 2194 * @throws { BusinessError } 15100001 - Over max limits. 2195 * @throws { BusinessError } 15100005 - Database or result set already closed. 2196 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2197 * @since 10 2198 */ 2199 on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void; 2200 2201 /** 2202 * Register a databases synchronization callback to the database. 2203 * <p> Sync result is returned through asynchronous callback. 2204 * 2205 * @param { 'syncComplete' } event - Subscribed event name, fixed as 'syncComplete', indicates the synchronization completion event. 2206 * @param { Callback<Array<[string, number]>> } syncCallback - {Array<[string, number]>}: the 2207 * deviceId and it's corresponding synchronization result which 0 means synchronization success 2208 * and otherwise failed. 2209 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2210 * <br>2.Incorrect parameters types. 2211 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2212 * @since 9 2213 */ 2214 on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void; 2215 2216 /** 2217 * Unsubscribe from the SingleKVStore database based on the specified subscribeType and listener. 2218 * 2219 * @param { 'dataChange' } event - The unsubscribe event name, fixed as 'dataChange', indicates the data change event. 2220 * @param { Callback<ChangeNotification> } listener - {ChangeNotification}: the {@code ChangeNotification} 2221 * object indicates the data change events in the distributed database. 2222 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2223 * <br>2.Incorrect parameters types. 2224 * @throws { BusinessError } 15100005 - Database or result set already closed. 2225 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2226 * @since 9 2227 */ 2228 off(event: 'dataChange', listener?: Callback<ChangeNotification>): void; 2229 2230 /** 2231 * Unregister the database synchronization callback. 2232 * 2233 * @param { 'syncComplete' } event - The unsubscribe event name, fixed as 'syncComplete', indicates the synchronization completion event. 2234 * @param { Callback<Array<[string, number]>> } syncCallback - {Array<[string, number]>}: the 2235 * deviceId and it's corresponding synchronization result which 0 means synchronization success 2236 * and otherwise failed. 2237 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2238 * <br>2.Incorrect parameters types. 2239 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2240 * @since 9 2241 */ 2242 off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void; 2243 2244 /** 2245 * Get the security level of the database. 2246 * 2247 * @param { AsyncCallback<SecurityLevel> } callback - {SecurityLevel}: the {@code SecurityLevel} 2248 * object indicates the security level of the database. 2249 * @throws { BusinessError } 15100005 - Database or result set already closed. 2250 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2251 * @since 9 2252 */ 2253 getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void; 2254 2255 /** 2256 * Get the security level of the database. 2257 * 2258 * @returns { Promise<SecurityLevel> } {SecurityLevel}: the {@code SecurityLevel} object indicates 2259 * the security level of the database. 2260 * @throws { BusinessError } 15100005 - Database or result set already closed. 2261 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2262 * @since 9 2263 */ 2264 getSecurityLevel(): Promise<SecurityLevel>; 2265 } 2266 2267 /** 2268 * Provides methods related to device-collaboration distributed databases. 2269 * <p>To create a {@code DeviceKVStore} database, you can use the {@link data.distributed.common.KVManager.getKVStore(Options, String)} 2270 * method with {@code KVStoreType} set to {@code DEVICE_COLLABORATION} for the input parameter Options. This database manages distributed 2271 * data by device, and cannot modify data synchronized from remote devices. When an application writes a key-value pair entry 2272 * into the database, the system automatically adds the ID of the device running the application to the key. 2273 * 2274 * @interface DeviceKVStore 2275 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2276 * @since 9 2277 */ 2278 interface DeviceKVStore extends SingleKVStore { 2279 /** 2280 * Obtains the value matching the local device ID and specified key. 2281 * 2282 * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. 2283 * @param { AsyncCallback<boolean | string | number | Uint8Array> } callback - 2284 * {Uint8Array|string|boolean|number}: the returned value specified by the local device ID and specified key. 2285 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2286 * <br>2.Incorrect parameters types; 2287 * <br>3.Parameter verification failed. 2288 * @throws { BusinessError } 15100003 - Database corrupted. 2289 * @throws { BusinessError } 15100004 - Not found. 2290 * @throws { BusinessError } 15100005 - Database or result set already closed. 2291 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2292 * @since 9 2293 */ 2294 get(key: string, callback: AsyncCallback<boolean | string | number | Uint8Array>): void; 2295 2296 /** 2297 * Obtains the value matching the local device ID and specified key. 2298 * 2299 * @param { string } key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. 2300 * @returns { Promise<boolean | string | number | Uint8Array> } 2301 * {Uint8Array|string|boolean|number}: the returned value specified by the local device ID and specified key. 2302 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2303 * <br>2.Incorrect parameters types; 2304 * <br>3.Parameter verification failed. 2305 * @throws { BusinessError } 15100003 - Database corrupted. 2306 * @throws { BusinessError } 15100004 - Not found. 2307 * @throws { BusinessError } 15100005 - Database or result set already closed. 2308 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2309 * @since 9 2310 */ 2311 get(key: string): Promise<boolean | string | number | Uint8Array>; 2312 2313 /** 2314 * Obtains the value matching a specified device ID and key. 2315 * 2316 * @param { string } deviceId - Indicates the device to be queried. 2317 * @param { string } key - Indicates the key of the value to be queried. The length must be less than {@code MAX_KEY_LENGTH}. 2318 * @param { AsyncCallback<boolean | string | number | Uint8Array> } callback - 2319 * {boolean | string | number | Uint8Array}: the returned value specified by the deviceId and key. 2320 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2321 * <br>2.Incorrect parameters types; 2322 * <br>3.Parameter verification failed. 2323 * @throws { BusinessError } 15100003 - Database corrupted. 2324 * @throws { BusinessError } 15100004 - Not found. 2325 * @throws { BusinessError } 15100005 - Database or result set already closed. 2326 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2327 * @since 9 2328 */ 2329 get(deviceId: string, key: string, callback: AsyncCallback<boolean | string | number | Uint8Array>): void; 2330 2331 /** 2332 * Obtains the value matching a specified device ID and key. 2333 * 2334 * @param { string } deviceId - Indicates the device to be queried. 2335 * @param { string } key - Indicates the key of the value to be queried. The length must be less than {@code MAX_KEY_LENGTH}. 2336 * @returns { Promise<boolean | string | number | Uint8Array> } 2337 * {Uint8Array|string|boolean|number}: the returned value specified by the deviceId and key. 2338 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2339 * <br>2.Incorrect parameters types; 2340 * <br>3.Parameter verification failed. 2341 * @throws { BusinessError } 15100003 - Database corrupted. 2342 * @throws { BusinessError } 15100004 - Not found. 2343 * @throws { BusinessError } 15100005 - Database or result set already closed. 2344 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2345 * @since 9 2346 */ 2347 get(deviceId: string, key: string): Promise<boolean | string | number | Uint8Array>; 2348 2349 /** 2350 * Obtains all key-value pairs that match the local device ID and specified key prefix. 2351 * 2352 * @param { string } keyPrefix - Indicates the key prefix to match. 2353 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 2354 * that match the local device ID and specified key prefix. 2355 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2356 * <br>2.Incorrect parameters types. 2357 * @throws { BusinessError } 15100003 - Database corrupted. 2358 * @throws { BusinessError } 15100005 - Database or result set already closed. 2359 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2360 * @since 9 2361 */ 2362 getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void; 2363 2364 /** 2365 * Obtains all key-value pairs that match the local device ID and specified key prefix. 2366 * 2367 * @param { string } keyPrefix - Indicates the key prefix to match. 2368 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs that match the 2369 * local device ID and specified key prefix. 2370 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2371 * <br>2.Incorrect parameters types. 2372 * @throws { BusinessError } 15100003 - Database corrupted. 2373 * @throws { BusinessError } 15100005 - Database or result set already closed. 2374 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2375 * @since 9 2376 */ 2377 getEntries(keyPrefix: string): Promise<Entry[]>; 2378 2379 /** 2380 * Obtains all key-value pairs matching a specified device ID and key prefix. 2381 * 2382 * @param { string } deviceId - Identifies the device whose data is to be queried. 2383 * @param { string } keyPrefix - Indicates the key prefix to match. 2384 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 2385 * that match the specified deviceId and key prefix. 2386 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2387 * <br>2.Incorrect parameters types. 2388 * @throws { BusinessError } 15100003 - Database corrupted. 2389 * @throws { BusinessError } 15100005 - Database or result set already closed. 2390 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2391 * @since 9 2392 */ 2393 getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void; 2394 2395 /** 2396 * Obtains all key-value pairs matching a specified device ID and key prefix. 2397 * 2398 * @param { string } deviceId - Identifies the device whose data is to be queried. 2399 * @param { string } keyPrefix - Indicates the key prefix to match. 2400 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs that match the 2401 * specified deviceId and key prefix. 2402 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2403 * <br>2.Incorrect parameters types. 2404 * @throws { BusinessError } 15100003 - Database corrupted. 2405 * @throws { BusinessError } 15100005 - Database or result set already closed. 2406 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2407 * @since 9 2408 */ 2409 getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]>; 2410 2411 /** 2412 * Obtains the list of key-value pairs matching the local device ID and specified {@code Query} object. 2413 * 2414 * @param { Query } query - Indicates the {@code Query} object. 2415 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 2416 * matching the local device ID and specified {@code Query} object. 2417 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2418 * <br>2.Incorrect parameters types. 2419 * @throws { BusinessError } 15100003 - Database corrupted. 2420 * @throws { BusinessError } 15100005 - Database or result set already closed. 2421 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2422 * @since 9 2423 */ 2424 getEntries(query: Query, callback: AsyncCallback<Entry[]>): void; 2425 2426 /** 2427 * Obtains the list of key-value pairs matching the local device ID and specified {@code Query} object. 2428 * 2429 * @param { Query } query - Indicates the {@code Query} object. 2430 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs matching the local device ID and 2431 * specified {@code Query} object. 2432 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2433 * <br>2.Incorrect parameters types. 2434 * @throws { BusinessError } 15100003 - Database corrupted. 2435 * @throws { BusinessError } 15100005 - Database or result set already closed. 2436 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2437 * @since 9 2438 */ 2439 getEntries(query: Query): Promise<Entry[]>; 2440 2441 /** 2442 * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. 2443 * 2444 * @param { string } deviceId - Indicates the ID of the device to which the key-value pairs belong. 2445 * @param { Query } query - Indicates the {@code Query} object. 2446 * @param { AsyncCallback<Entry[]> } callback - {Entry[]}: the list of all key-value pairs 2447 * matching the specified deviceId and {@code Query} object. 2448 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2449 * <br>2.Incorrect parameters types. 2450 * @throws { BusinessError } 15100003 - Database corrupted. 2451 * @throws { BusinessError } 15100005 - Database or result set already closed. 2452 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2453 * @since 9 2454 */ 2455 getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void; 2456 2457 /** 2458 * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. 2459 * 2460 * @param { string } deviceId - Indicates the ID of the device to which the key-value pairs belong. 2461 * @param { Query } query - Indicates the {@code Query} object. 2462 * @returns { Promise<Entry[]> } {Entry[]}: the list of all key-value pairs matching the 2463 * specified deviceId and {@code Query} object. 2464 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2465 * <br>2.Incorrect parameters types. 2466 * @throws { BusinessError } 15100003 - Database corrupted. 2467 * @throws { BusinessError } 15100005 - Database or result set already closed. 2468 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2469 * @since 9 2470 */ 2471 getEntries(deviceId: string, query: Query): Promise<Entry[]>; 2472 2473 /** 2474 * Obtains the result set with the local device ID and specified prefix from a {@code DeviceKVStore} database. 2475 * The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. 2476 * Each {@code DeviceKVStore} instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. 2477 * If you have created four objects, calling this method will return a failure. Therefore, you are advised to 2478 * call the closeResultSet method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 2479 * 2480 * @param { string } keyPrefix - Indicates the key prefix to match. 2481 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2482 * object matching the local device ID and specified keyPrefix. 2483 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2484 * <br>2.Incorrect parameters types. 2485 * @throws { BusinessError } 15100003 - Database corrupted. 2486 * @throws { BusinessError } 15100005 - Database or result set already closed. 2487 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2488 * @since 9 2489 */ 2490 /** 2491 * Obtains the result set with the local device ID and specified prefix from a {@code DeviceKVStore} database. 2492 * The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. 2493 * Each {@code DeviceKVStore} instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. 2494 * If you have created four objects, calling this method will return a failure. Therefore, you are advised to 2495 * call the closeResultSet method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 2496 * 2497 * @param { string } keyPrefix - Indicates the key prefix to match. 2498 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2499 * object matching the local device ID and specified keyPrefix. 2500 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2501 * <br>2.Incorrect parameters types. 2502 * @throws { BusinessError } 15100001 - Over max limits. 2503 * @throws { BusinessError } 15100003 - Database corrupted. 2504 * @throws { BusinessError } 15100005 - Database or result set already closed. 2505 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2506 * @since 10 2507 */ 2508 getResultSet(keyPrefix: string, callback: AsyncCallback<KVStoreResultSet>): void; 2509 2510 /** 2511 * Obtains the result set with the local device ID and specified prefix from a {@code DeviceKVStore} database. 2512 * The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. 2513 * Each {@code DeviceKVStore} instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. 2514 * If you have created four objects, calling this method will return a failure. Therefore, you are advised to 2515 * call the closeResultSet method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 2516 * 2517 * @param { string } keyPrefix - Indicates the key prefix to match. 2518 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2519 * object matching the local device ID and specified keyPrefix. 2520 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2521 * <br>2.Incorrect parameters types. 2522 * @throws { BusinessError } 15100003 - Database corrupted. 2523 * @throws { BusinessError } 15100005 - Database or result set already closed. 2524 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2525 * @since 9 2526 */ 2527 /** 2528 * Obtains the result set with the local device ID and specified prefix from a {@code DeviceKVStore} database. 2529 * The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. 2530 * Each {@code DeviceKVStore} instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. 2531 * If you have created four objects, calling this method will return a failure. Therefore, you are advised to 2532 * call the closeResultSet method to close unnecessary {@code KVStoreResultSet} objects in a timely manner. 2533 * 2534 * @param { string } keyPrefix - Indicates the key prefix to match. 2535 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2536 * object matching the local device ID and specified keyPrefix. 2537 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2538 * <br>2.Incorrect parameters types. 2539 * @throws { BusinessError } 15100001 - Over max limits. 2540 * @throws { BusinessError } 15100003 - Database corrupted. 2541 * @throws { BusinessError } 15100005 - Database or result set already closed. 2542 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2543 * @since 10 2544 */ 2545 getResultSet(keyPrefix: string): Promise<KVStoreResultSet>; 2546 2547 /** 2548 * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. 2549 * <p>The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code DeviceKVStore} 2550 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, 2551 * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary 2552 * {@code KVStoreResultSet} objects in a timely manner. 2553 * 2554 * @param { string } deviceId - Identifies the device whose data is to be queried. 2555 * @param { string } keyPrefix - Indicates the key prefix to match. 2556 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2557 * object matching the specified deviceId and keyPrefix. 2558 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2559 * <br>2.Incorrect parameters types. 2560 * @throws { BusinessError } 15100003 - Database corrupted. 2561 * @throws { BusinessError } 15100005 - Database or result set already closed. 2562 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2563 * @since 9 2564 */ 2565 /** 2566 * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. 2567 * <p>The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code DeviceKVStore} 2568 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, 2569 * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary 2570 * {@code KVStoreResultSet} objects in a timely manner. 2571 * 2572 * @param { string } deviceId - Identifies the device whose data is to be queried. 2573 * @param { string } keyPrefix - Indicates the key prefix to match. 2574 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2575 * object matching the specified deviceId and keyPrefix. 2576 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2577 * <br>2.Incorrect parameters types. 2578 * @throws { BusinessError } 15100001 - Over max limits. 2579 * @throws { BusinessError } 15100003 - Database corrupted. 2580 * @throws { BusinessError } 15100005 - Database or result set already closed. 2581 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2582 * @since 10 2583 */ 2584 getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KVStoreResultSet>): void; 2585 2586 /** 2587 * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. 2588 * <p>The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code DeviceKVStore} 2589 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, 2590 * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary 2591 * {@code KVStoreResultSet} objects in a timely manner. 2592 * 2593 * @param { string } deviceId - Identifies the device whose data is to be queried. 2594 * @param { string } keyPrefix - Indicates the key prefix to match. 2595 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2596 * object matching the specified deviceId and keyPrefix. 2597 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2598 * <br>2.Incorrect parameters types. 2599 * @throws { BusinessError } 15100003 - Database corrupted. 2600 * @throws { BusinessError } 15100005 - Database or result set already closed. 2601 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2602 * @since 9 2603 */ 2604 /** 2605 * Obtains the {@code KVStoreResultSet} object matching the specified device ID and key prefix. 2606 * <p>The {@code KVStoreResultSet} object can be used to query all key-value pairs that meet the search criteria. Each {@code DeviceKVStore} 2607 * instance can have a maximum of four {@code KVStoreResultSet} objects at the same time. If you have created four objects, 2608 * calling this method will return a failure. Therefore, you are advised to call the closeResultSet method to close unnecessary 2609 * {@code KVStoreResultSet} objects in a timely manner. 2610 * 2611 * @param { string } deviceId - Identifies the device whose data is to be queried. 2612 * @param { string } keyPrefix - Indicates the key prefix to match. 2613 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2614 * object matching the specified deviceId and keyPrefix. 2615 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2616 * <br>2.Incorrect parameters types. 2617 * @throws { BusinessError } 15100001 - Over max limits. 2618 * @throws { BusinessError } 15100003 - Database corrupted. 2619 * @throws { BusinessError } 15100005 - Database or result set already closed. 2620 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2621 * @since 10 2622 */ 2623 getResultSet(deviceId: string, keyPrefix: string): Promise<KVStoreResultSet>; 2624 2625 /** 2626 * Obtains the {@code KVStoreResultSet} object matching the local device ID and specified {@code Query} object. 2627 * 2628 * @param { Query } query - Indicates the {@code Query} object. 2629 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2630 * object matching the local device ID and specified {@code Query} object. 2631 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2632 * <br>2.Incorrect parameters types. 2633 * @throws { BusinessError } 15100003 - Database corrupted. 2634 * @throws { BusinessError } 15100005 - Database or result set already closed. 2635 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2636 * @since 9 2637 */ 2638 /** 2639 * Obtains the {@code KVStoreResultSet} object matching the local device ID and specified {@code Query} object. 2640 * 2641 * @param { Query } query - Indicates the {@code Query} object. 2642 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2643 * object matching the local device ID and specified {@code Query} object. 2644 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2645 * <br>2.Incorrect parameters types. 2646 * @throws { BusinessError } 15100001 - Over max limits. 2647 * @throws { BusinessError } 15100003 - Database corrupted. 2648 * @throws { BusinessError } 15100005 - Database or result set already closed. 2649 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2650 * @since 10 2651 */ 2652 getResultSet(query: Query, callback: AsyncCallback<KVStoreResultSet>): void; 2653 2654 /** 2655 * Obtains the {@code KVStoreResultSet} object matching the local device ID and specified {@code Query} object. 2656 * 2657 * @param { Query } query - Indicates the {@code Query} object. 2658 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2659 * object matching the local device ID and specified {@code Query} object. 2660 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2661 * <br>2.Incorrect parameters types. 2662 * @throws { BusinessError } 15100003 - Database corrupted. 2663 * @throws { BusinessError } 15100005 - Database or result set already closed. 2664 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2665 * @since 9 2666 */ 2667 /** 2668 * Obtains the {@code KVStoreResultSet} object matching the local device ID and specified {@code Query} object. 2669 * 2670 * @param { Query } query - Indicates the {@code Query} object. 2671 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2672 * object matching the local device ID and specified {@code Query} object. 2673 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2674 * <br>2.Incorrect parameters types. 2675 * @throws { BusinessError } 15100001 - Over max limits. 2676 * @throws { BusinessError } 15100003 - Database corrupted. 2677 * @throws { BusinessError } 15100005 - Database or result set already closed. 2678 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2679 * @since 10 2680 */ 2681 getResultSet(query: Query): Promise<KVStoreResultSet>; 2682 2683 /** 2684 * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. 2685 * 2686 * @param { string } deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. 2687 * @param { Query } query - Indicates the {@code Query} object. 2688 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2689 * object matching the specified deviceId and {@code Query} object. 2690 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2691 * <br>2.Incorrect parameters types. 2692 * @throws { BusinessError } 15100003 - Database corrupted. 2693 * @throws { BusinessError } 15100005 - Database or result set already closed. 2694 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2695 * @since 9 2696 */ 2697 /** 2698 * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. 2699 * 2700 * @param { string } deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. 2701 * @param { Query } query - Indicates the {@code Query} object. 2702 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2703 * object matching the specified deviceId and {@code Query} object. 2704 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2705 * <br>2.Incorrect parameters types. 2706 * @throws { BusinessError } 15100001 - Over max limits. 2707 * @throws { BusinessError } 15100003 - Database corrupted. 2708 * @throws { BusinessError } 15100005 - Database or result set already closed. 2709 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2710 * @since 10 2711 */ 2712 getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KVStoreResultSet>): void; 2713 2714 /** 2715 * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. 2716 * 2717 * @param { string } deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. 2718 * @param { Query } query - Indicates the {@code Query} object. 2719 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2720 * object matching the specified deviceId and {@code Query} object. 2721 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2722 * <br>2.Incorrect parameters types. 2723 * @throws { BusinessError } 15100003 - Database corrupted. 2724 * @throws { BusinessError } 15100005 - Database or result set already closed. 2725 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2726 * @since 9 2727 */ 2728 /** 2729 * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. 2730 * 2731 * @param { string } deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. 2732 * @param { Query } query - Indicates the {@code Query} object. 2733 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2734 * object matching the specified deviceId and {@code Query} object. 2735 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2736 * <br>2.Incorrect parameters types. 2737 * @throws { BusinessError } 15100001 - Over max limits. 2738 * @throws { BusinessError } 15100003 - Database corrupted. 2739 * @throws { BusinessError } 15100005 - Database or result set already closed. 2740 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2741 * @since 10 2742 */ 2743 getResultSet(deviceId: string, query: Query): Promise<KVStoreResultSet>; 2744 2745 /** 2746 * Obtains the KVStoreResultSet object matching the local device ID and specified predicate object. 2747 * 2748 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 2749 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2750 * object matching the local device ID and specified {@code dataSharePredicates.DataSharePredicates} object. 2751 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2752 * <br>2.Incorrect parameters types. 2753 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2754 * @throws { BusinessError } 15100003 - Database corrupted. 2755 * @throws { BusinessError } 15100005 - Database or result set already closed. 2756 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2757 * @systemapi 2758 * @StageModelOnly 2759 * @since 9 2760 */ 2761 /** 2762 * Obtains the KVStoreResultSet object matching the local device ID and specified predicate object. 2763 * 2764 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 2765 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2766 * object matching the local device ID and specified {@code dataSharePredicates.DataSharePredicates} object. 2767 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2768 * <br>2.Incorrect parameters types. 2769 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2770 * @throws { BusinessError } 15100001 - Over max limits. 2771 * @throws { BusinessError } 15100003 - Database corrupted. 2772 * @throws { BusinessError } 15100005 - Database or result set already closed. 2773 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2774 * @systemapi 2775 * @StageModelOnly 2776 * @since 10 2777 */ 2778 getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<KVStoreResultSet>): void; 2779 2780 /** 2781 * Obtains the KVStoreResultSet object matching the local device ID and specified predicate object. 2782 * 2783 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 2784 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2785 * object matching the local device ID and specified {@code dataSharePredicates.DataSharePredicates} object. 2786 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2787 * <br>2.Incorrect parameters types. 2788 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2789 * @throws { BusinessError } 15100003 - Database corrupted. 2790 * @throws { BusinessError } 15100005 - Database or result set already closed. 2791 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2792 * @systemapi 2793 * @StageModelOnly 2794 * @since 9 2795 */ 2796 /** 2797 * Obtains the KVStoreResultSet object matching the local device ID and specified predicate object. 2798 * 2799 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the datasharePredicates. 2800 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2801 * object matching the local device ID and specified {@code dataSharePredicates.DataSharePredicates} object. 2802 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2803 * <br>2.Incorrect parameters types. 2804 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2805 * @throws { BusinessError } 15100001 - Over max limits. 2806 * @throws { BusinessError } 15100003 - Database corrupted. 2807 * @throws { BusinessError } 15100005 - Database or result set already closed. 2808 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2809 * @systemapi 2810 * @StageModelOnly 2811 * @since 10 2812 */ 2813 getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<KVStoreResultSet>; 2814 2815 /** 2816 * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. 2817 * 2818 * @param { string } deviceId Indicates the ID of the device to which the results belong. 2819 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 2820 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2821 * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. 2822 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2823 * <br>2.Incorrect parameters types. 2824 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2825 * @throws { BusinessError } 15100003 - Database corrupted. 2826 * @throws { BusinessError } 15100005 - Database or result set already closed. 2827 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2828 * @systemapi 2829 * @StageModelOnly 2830 * @since 9 2831 */ 2832 /** 2833 * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. 2834 * 2835 * @param { string } deviceId Indicates the ID of the device to which the results belong. 2836 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 2837 * @param { AsyncCallback<KVStoreResultSet> } callback - {KVStoreResultSet}: the {@code KVStoreResultSet} 2838 * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. 2839 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2840 * <br>2.Incorrect parameters types. 2841 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2842 * @throws { BusinessError } 15100001 - Over max limits. 2843 * @throws { BusinessError } 15100003 - Database corrupted. 2844 * @throws { BusinessError } 15100005 - Database or result set already closed. 2845 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2846 * @systemapi 2847 * @StageModelOnly 2848 * @since 10 2849 */ 2850 getResultSet( 2851 deviceId: string, 2852 predicates: dataSharePredicates.DataSharePredicates, 2853 callback: AsyncCallback<KVStoreResultSet> 2854 ): void; 2855 2856 /** 2857 * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. 2858 * 2859 * @param { string } deviceId Indicates the ID of the device to which the results belong. 2860 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 2861 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2862 * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. 2863 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2864 * <br>2.Incorrect parameters types. 2865 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2866 * @throws { BusinessError } 15100003 - Database corrupted. 2867 * @throws { BusinessError } 15100005 - Database or result set already closed. 2868 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2869 * @systemapi 2870 * @StageModelOnly 2871 * @since 9 2872 */ 2873 /** 2874 * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. 2875 * 2876 * @param { string } deviceId Indicates the ID of the device to which the results belong. 2877 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates the dataSharePredicates. 2878 * @returns { Promise<KVStoreResultSet> } {KVStoreResultSet}: the {@code KVStoreResultSet} 2879 * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. 2880 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2881 * <br>2.Incorrect parameters types. 2882 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 2883 * @throws { BusinessError } 15100001 - Over max limits. 2884 * @throws { BusinessError } 15100003 - Database corrupted. 2885 * @throws { BusinessError } 15100005 - Database or result set already closed. 2886 * @syscap SystemCapability.DistributedDataManager.DataShare.Provider 2887 * @systemapi 2888 * @StageModelOnly 2889 * @since 10 2890 */ 2891 getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise<KVStoreResultSet>; 2892 2893 /** 2894 * Obtains the number of results matching the local device ID and specified {@code Query} object. 2895 * 2896 * @param { Query } query - Indicates the {@code Query} object. 2897 * @param { AsyncCallback<number> } callback - {number}: the number of results matching the 2898 * local device ID and specified {@code Query} object. 2899 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2900 * <br>2.Incorrect parameters types. 2901 * @throws { BusinessError } 15100003 - Database corrupted. 2902 * @throws { BusinessError } 15100005 - Database or result set already closed. 2903 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2904 * @since 9 2905 */ 2906 getResultSize(query: Query, callback: AsyncCallback<number>): void; 2907 2908 /** 2909 * Obtains the number of results matching the local device ID and specified {@code Query} object. 2910 * 2911 * @param { Query } query - Indicates the {@code Query} object. 2912 * @returns { Promise<number> } {number}: the number of results matching the local device ID and specified 2913 * {@code Query} object. 2914 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2915 * <br>2.Incorrect parameters types. 2916 * @throws { BusinessError } 15100003 - Database corrupted. 2917 * @throws { BusinessError } 15100005 - Database or result set already closed. 2918 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2919 * @since 9 2920 */ 2921 getResultSize(query: Query): Promise<number>; 2922 2923 /** 2924 * Obtains the number of results matching a specified device ID and {@code Query} object. 2925 * 2926 * @param { string } deviceId - Indicates the ID of the device to which the results belong. 2927 * @param { Query } query - Indicates the {@code Query} object. 2928 * @param { AsyncCallback<number> } callback - {number}: the number of results matching the 2929 * specified deviceId and {@code Query} object. 2930 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2931 * <br>2.Incorrect parameters types. 2932 * @throws { BusinessError } 15100003 - Database corrupted. 2933 * @throws { BusinessError } 15100005 - Database or result set already closed. 2934 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2935 * @since 9 2936 */ 2937 getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void; 2938 2939 /** 2940 * Obtains the number of results matching a specified device ID and {@code Query} object. 2941 * 2942 * @param { string } deviceId - Indicates the ID of the device to which the results belong. 2943 * @param { Query } query - Indicates the {@code Query} object. 2944 * @returns { Promise<number> } {number}: the number of results matching the specified 2945 * deviceId and {@code Query} object. 2946 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2947 * <br>2.Incorrect parameters types. 2948 * @throws { BusinessError } 15100003 - Database corrupted. 2949 * @throws { BusinessError } 15100005 - Database or result set already closed. 2950 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 2951 * @since 9 2952 */ 2953 getResultSize(deviceId: string, query: Query): Promise<number>; 2954 } 2955 2956 /** 2957 * Creates a {@link KVManager} instance based on the configuration information. 2958 * <p>You must pass {@link KVManagerConfig} to provide configuration information 2959 * to create a {@link KVManager} instance. 2960 * 2961 * @param { KVManagerConfig } config - Indicates the KVStore configuration information, 2962 * including the package name and context, and package name can not be empty. 2963 * @returns { KVManager } : the {@code KVManager} instance. 2964 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2965 * <br>2.Incorrect parameters types; 2966 * <br>3.Parameter verification failed. 2967 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2968 * @since 9 2969 */ 2970 function createKVManager(config: KVManagerConfig): KVManager; 2971 2972 /** 2973 * Provides interfaces to manage a {@code SingleKVStore} database, including obtaining, closing, and deleting the {@code SingleKVStore}. 2974 * 2975 * @interface KVManager 2976 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2977 * @since 9 2978 */ 2979 interface KVManager { 2980 /** 2981 * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. 2982 * 2983 * @param { string } storeId - Identifies the KVStore database. The value of this parameter must be unique 2984 * for the same application, and different applications can share the same value. The storeId can consist 2985 * of only letters, digits, and underscores (_), and cannot exceed 128 characters. 2986 * @param { Options } options - Indicates the {@code Options} object used for creating and 2987 * obtaining the KVStore database. 2988 * @param { AsyncCallback<T> } callback - {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. 2989 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2990 * <br>2.Incorrect parameters types; 2991 * <br>3.Parameter verification failed. 2992 * @throws { BusinessError } 15100002 - Open existed database with changed options. 2993 * @throws { BusinessError } 15100003 - Database corrupted. 2994 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 2995 * @since 9 2996 */ 2997 getKVStore<T>(storeId: string, options: Options, callback: AsyncCallback<T>): void; 2998 2999 /** 3000 * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. 3001 * 3002 * @param { string } storeId - Identifies the KVStore database. The value of this parameter must be unique 3003 * for the same application, and different applications can share the same value. The storeId can consist 3004 * of only letters, digits, and underscores (_), and cannot exceed 128 characters. 3005 * @param { Options } options - Indicates the {@code Options} object used for creating and 3006 * obtaining the KVStore database. 3007 * @returns { Promise<T> } {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. 3008 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3009 * <br>2.Incorrect parameters types; 3010 * <br>3.Parameter verification failed. 3011 * @throws { BusinessError } 15100002 - Open existed database with changed options. 3012 * @throws { BusinessError } 15100003 - Database corrupted. 3013 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3014 * @since 9 3015 */ 3016 getKVStore<T>(storeId: string, options: Options): Promise<T>; 3017 3018 /** 3019 * Closes the KVStore database. 3020 * <p>Warning: This method is not thread-safe. If you call this method to stop a KVStore database that is running, your 3021 * thread may crash. 3022 * <p>The KVStore database to close must be an object created by using the {@code getKVStore} method. Before using this 3023 * method, release the resources created for the database, for example, {@code KVStoreResultSet} for KVStore, otherwise 3024 * closing the database will fail. 3025 * 3026 * @param { string } appId - Identifies the application that the database belong to, and cannot exceed 256 characters. 3027 * @param { string } storeId - Identifies the KVStore database to close. The storeId can consist of only letters, digits, 3028 * and underscores (_), and cannot exceed 128 characters. 3029 * @param { AsyncCallback<void> } callback - the callback of closeKVStore. 3030 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3031 * <br>2.Parameter verification failed. 3032 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3033 * @since 9 3034 */ 3035 closeKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void; 3036 3037 /** 3038 * Closes the KVStore database. 3039 * <p>Warning: This method is not thread-safe. If you call this method to stop a KVStore database that is running, your 3040 * thread may crash. 3041 * <p>The KVStore database to close must be an object created by using the {@code getKVStore} method. Before using this 3042 * method, release the resources created for the database, for example, {@code KVStoreResultSet} for KVStore, otherwise 3043 * closing the database will fail. 3044 * 3045 * @param { string } appId - Identifies the application that the database belong to, and cannot exceed 256 characters. 3046 * @param { string } storeId - Identifies the KVStore database to close. The storeId can consist of only letters, digits, 3047 * and underscores (_), and cannot exceed 128 characters. 3048 * @returns { Promise<void> } the promise returned by the function. 3049 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3050 * <br>2.Parameter verification failed. 3051 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3052 * @since 9 3053 */ 3054 closeKVStore(appId: string, storeId: string): Promise<void>; 3055 3056 /** 3057 * Deletes the KVStore database identified by storeId. 3058 * <p>Before using this method, close all KVStore instances in use that are identified by the same storeId. 3059 * <p>You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be 3060 * lost. 3061 * 3062 * @param { string } appId - Identifies the application that the database belong to, and cannot exceed 256 characters. 3063 * @param { string } storeId - Identifies the KVStore database to delete. The storeId can consist of only letters, digits, 3064 * and underscores (_), and cannot exceed 128 characters. 3065 * @param { AsyncCallback<void> } callback - the callback of deleteKVStore. 3066 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3067 * <br>2.Parameter verification failed. 3068 * @throws { BusinessError } 15100004 - Not found. 3069 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3070 * @since 9 3071 */ 3072 deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void; 3073 3074 /** 3075 * Deletes the KVStore database identified by storeId. 3076 * <p>Before using this method, close all KVStore instances in use that are identified by the same storeId. 3077 * <p>You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be 3078 * lost. 3079 * 3080 * @param { string } appId - Identifies the application that the database belong to, and cannot exceed 256 characters. 3081 * @param { string } storeId - Identifies the KVStore database to delete. The storeId can consist of only letters, digits, 3082 * and underscores (_), and cannot exceed 128 characters. 3083 * @returns { Promise<void> } the promise returned by the function. 3084 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3085 * <br>2.Parameter verification failed. 3086 * @throws { BusinessError } 15100004 - Not found. 3087 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3088 * @since 9 3089 */ 3090 deleteKVStore(appId: string, storeId: string): Promise<void>; 3091 3092 /** 3093 * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by 3094 * calling the {@code deleteKVStore} method. 3095 * 3096 * @param { string } appId - Identifies the application that obtains the databases, and cannot exceed 256 characters. 3097 * @param { AsyncCallback<string[]> } callback - {string[]}: the storeId of all created KVStore databases. 3098 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3099 * <br>2.Parameter verification failed. 3100 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3101 * @since 9 3102 */ 3103 getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void; 3104 3105 /** 3106 * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by 3107 * calling the {@code deleteKVStore} method. 3108 * 3109 * @param { string } appId - Identifies the application that obtains the databases, and cannot exceed 256 characters. 3110 * @returns { Promise<string[]> } {string[]}: the storeId of all created KVStore databases. 3111 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified. 3112 * <br>2.Parameter verification failed. 3113 * @syscap SystemCapability.DistributedDataManager.KVStore.Core 3114 * @since 9 3115 */ 3116 getAllKVStoreId(appId: string): Promise<string[]>; 3117 3118 /** 3119 * Register a death callback to get notification when the data manager service is terminated. 3120 * <p>If the data manager service is terminated,you need to re-subscribe to data change notifications and synchronization 3121 * completion notifications, and calling the sync method will return a failure. 3122 * 3123 * @param { 'distributedDataServiceDie' } event - Subscribed event name, fixed as 'distributedDataServiceDie', as a service status change events. 3124 * @param { Callback<void> } deathCallback - callback to be invoked when the data manager service is terminated. 3125 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3126 * <br>2.Incorrect parameters types; 3127 * <br>3.Parameter verification failed. 3128 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 3129 * @since 9 3130 */ 3131 on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void; 3132 3133 /** 3134 * Unregister the death callback. Not notification will be received when the data manager service is terminated. 3135 * <p>The unregistered death callback must be a registered death callback of the database. If no death callback parameter 3136 * is passed, all database death callbacks will be unregistered. 3137 * 3138 * @param { 'distributedDataServiceDie' } event - Unsubscribe event name, fixed as 'distributedDataServiceDie', as a service status change events. 3139 * @param { Callback<void> } deathCallback - the data manager service is terminated callback which has been registered. 3140 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 3141 * <br>2.Incorrect parameters types; 3142 * <br>3.Parameter verification failed. 3143 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore 3144 * @since 9 3145 */ 3146 off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void; 3147 } 3148} 3149 3150export default distributedKVStore;