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 type { AsyncCallback } from './@ohos.base'; 22import Context from './application/Context'; 23import DataShareResultSet from './@ohos.data.DataShareResultSet'; 24import dataSharePredicates from './@ohos.data.dataSharePredicates'; 25import { ValuesBucket } from './@ohos.data.ValuesBucket'; 26 27/** 28 * This module provides the dataShare capability for consumer. 29 * 30 * @namespace dataShare 31 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 32 * @systemapi 33 * @stagemodelonly 34 * @since 9 35 */ 36declare namespace dataShare { 37 /** 38 * Manages create datashare helper options. 39 * 40 * @interface DataShareHelperOptions 41 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 42 * @systemapi 43 * @stagemodelonly 44 * @since 10 45 */ 46 interface DataShareHelperOptions { 47 /** 48 * Specifies whether the {@link DataShareHelper} in proxy mode. 49 * If value is true, the {@link DataShareHelper} to be created is in proxy mode, and all operations will not open provider APP as possible 50 * 51 * @type { ?boolean } 52 * @default false 53 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 54 * @systemapi 55 * @stagemodelonly 56 * @since 10 57 */ 58 isProxy?: boolean; 59 /** 60 * Specifies the time to wait for connecting extension, in seconds. 61 * 62 * @type { ?number } 63 * @default 2 64 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 65 * @systemapi 66 * @stagemodelonly 67 * @since 18 68 */ 69 waitTime?: number; 70 } 71 72 /** 73 * Obtains the dataShareHelper. 74 * 75 * @param { Context } context - Indicates the application context. 76 * @param { string } uri - Indicates the path of the file to open. 77 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 78 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 79 * 2. Incorrect parameters types. 80 * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully. 81 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 82 * @systemapi 83 * @stagemodelonly 84 * @since 9 85 */ 86 function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<DataShareHelper>): void; 87 /** 88 * Obtains the dataShareHelper. 89 * 90 * @param { Context } context - Indicates the application context. 91 * @param { string } uri - Indicates the path of the file to open. 92 * @param { DataShareHelperOptions } options - Indicates the optional config. 93 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 94 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 95 * 2. Incorrect parameters types. 96 * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully. 97 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 98 * @systemapi 99 * @stagemodelonly 100 * @since 10 101 */ 102 function createDataShareHelper( 103 context: Context, 104 uri: string, 105 options: DataShareHelperOptions, 106 callback: AsyncCallback<DataShareHelper> 107 ): void; 108 109 /** 110 * Obtains the dataShareHelper. 111 * 112 * @param { Context } context - Indicates the application context. 113 * @param { string } uri - Indicates the path of the file to open. 114 * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer. 115 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 116 * 2. Incorrect parameters types. 117 * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully. 118 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 119 * @systemapi 120 * @stagemodelonly 121 * @since 9 122 */ 123 /** 124 * Obtains the dataShareHelper. 125 * 126 * @param { Context } context - Indicates the application context. 127 * @param { string } uri - Indicates the path of the file to open. 128 * @param { DataShareHelperOptions } options - Indicates the optional config. 129 * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer. 130 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 131 * 2. Incorrect parameters types. 132 * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully. 133 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 134 * @systemapi 135 * @stagemodelonly 136 * @since 10 137 */ 138 function createDataShareHelper( 139 context: Context, 140 uri: string, 141 options?: DataShareHelperOptions 142 ): Promise<DataShareHelper>; 143 144 /** 145 * Enables silent access dynamically. 146 * 147 * @param { Context } context - Indicates the application context. 148 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 149 * @returns { Promise<void> } The promise returned by the function. 150 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 151 * 2. Incorrect parameters types. 152 * @throws { BusinessError } 15700011 - The URI is not exist. 153 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 154 * @systemapi 155 * @stagemodelonly 156 * @since 11 157 */ 158 function enableSilentProxy(context: Context, uri?: string): Promise<void>; 159 160 /** 161 * Disables silent access dynamically. 162 * 163 * @param { Context } context - Indicates the application context. 164 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 165 * @returns { Promise<void> } The promise returned by the function. 166 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 167 * 2. Incorrect parameters types. 168 * @throws { BusinessError } 15700011 - The URI is not exist. 169 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 170 * @systemapi 171 * @stagemodelonly 172 * @since 11 173 */ 174 function disableSilentProxy(context: Context, uri?: string): Promise<void>; 175 176 /** 177 * Specifies the {@link Template} id structure. 178 * A template is marked by the template id. Note that the template id is auto generated in {@link DataShareHelper#addTemplate}. 179 * After {@link DataShareHelper#addTemplate}, can use the template id to direct a template. 180 * 181 * @interface TemplateId 182 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 183 * @systemapi 184 * @stagemodelonly 185 * @since 10 186 */ 187 interface TemplateId { 188 /** 189 * Specifies the id of subscriber, who process the callback 190 * Same as subscriberId in {@link DataShareHelper#addTemplate} 191 * 192 * @type { string } 193 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 194 * @systemapi 195 * @stagemodelonly 196 * @since 10 197 */ 198 subscriberId: string; 199 /** 200 * Specifies the bundleName of template owner, who create the template 201 * Same as the caller's bundleName of {@link DataShareHelper#addTemplate} 202 * 203 * @type { string } 204 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 205 * @systemapi 206 * @stagemodelonly 207 * @since 10 208 */ 209 bundleNameOfOwner: string; 210 } 211 212 /** 213 * Specifies the published item structure. 214 * 215 * @interface PublishedItem 216 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 217 * @systemapi 218 * @stagemodelonly 219 * @since 10 220 */ 221 interface PublishedItem { 222 /** 223 * Specifies the key of the published data 224 * 225 * @type { string } 226 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 227 * @systemapi 228 * @stagemodelonly 229 * @since 10 230 */ 231 key: string; 232 /** 233 * Specifies the published data 234 * If the data is large, use ArrayBuffer. 235 * 236 * @type { string | ArrayBuffer } 237 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 238 * @systemapi 239 * @stagemodelonly 240 * @since 10 241 */ 242 data: string | ArrayBuffer; 243 /** 244 * Specifies the subscriber id 245 * 246 * @type { string } 247 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 248 * @systemapi 249 * @stagemodelonly 250 * @since 10 251 */ 252 subscriberId: string; 253 } 254 255 /** 256 * Specifies the change node structure of rdb store data in callback. 257 * 258 * @interface RdbDataChangeNode 259 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 260 * @systemapi 261 * @stagemodelonly 262 * @since 10 263 */ 264 interface RdbDataChangeNode { 265 /** 266 * Specifies the uri of the callback. 267 * 268 * @type { string } 269 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 270 * @systemapi 271 * @stagemodelonly 272 * @since 10 273 */ 274 uri: string; 275 /** 276 * Specifies the templateId of the callback. 277 * 278 * @type { TemplateId } 279 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 280 * @systemapi 281 * @stagemodelonly 282 * @since 10 283 */ 284 templateId: TemplateId; 285 /** 286 * Specifies the datas of the callback. 287 * every node is a json, json's key is [key of {@link Template#predicates} 288 * and value is the query result from rdb store query by value of{@link Template#predicates}]. 289 * 290 * @type { Array<string> } 291 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 292 * @systemapi 293 * @stagemodelonly 294 * @since 10 295 */ 296 data: Array<string>; 297 } 298 299 /** 300 * Specifies the change node structure of published data in callback. 301 * 302 * @interface PublishedDataChangeNode 303 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 304 * @systemapi 305 * @stagemodelonly 306 * @since 10 307 */ 308 interface PublishedDataChangeNode { 309 /** 310 * Specifies the bundleName of the callback. 311 * 312 * @type { string } 313 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 314 * @systemapi 315 * @stagemodelonly 316 * @since 10 317 */ 318 bundleName: string; 319 /** 320 * Specifies the datas of the callback. 321 * 322 * @type { Array<PublishedItem> } 323 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 324 * @systemapi 325 * @stagemodelonly 326 * @since 10 327 */ 328 data: Array<PublishedItem>; 329 } 330 331 /** 332 * Specifies the template structure in subscribe. 333 * 334 * @interface Template 335 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 336 * @systemapi 337 * @stagemodelonly 338 * @since 10 339 */ 340 interface Template { 341 /** 342 * Specifies the predicates of the template. 343 * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)} 344 * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data. 345 * 346 * @type { [key: string]: string } 347 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 348 * @systemapi 349 * @stagemodelonly 350 * @since 10 351 */ 352 /** 353 * Specifies the predicates of the template. 354 * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)} 355 * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data. 356 * 357 * @type { Record<string, string> } 358 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 359 * @systemapi 360 * @stagemodelonly 361 * @since 11 362 */ 363 predicates: Record<string, string>; 364 365 /** 366 * Specifies the scheduler sql of the template. 367 * When modify the subscribed uri's data, scheduler is auto called. 368 * 369 * @type { string } 370 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 371 * @systemapi 372 * @stagemodelonly 373 * @since 10 374 */ 375 scheduler: string; 376 377 /** 378 * Specifies the update sql of the template. 379 * The update is called after the predicates execution is complete. 380 * 381 * @type { ?string } 382 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 383 * @systemapi 384 * @stagemodelonly 385 * @since 18 386 */ 387 update?: string; 388 } 389 /** 390 * Specifies the operation result structure. 391 * 392 * @interface OperationResult 393 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 394 * @systemapi 395 * @stagemodelonly 396 * @since 10 397 */ 398 interface OperationResult { 399 /** 400 * Specifies the key of the operation result. 401 * 402 * @type { string } 403 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 404 * @systemapi 405 * @stagemodelonly 406 * @since 10 407 */ 408 key: string; 409 410 /** 411 * Specifies the operation result. 412 * 413 * @type { number } 414 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 415 * @systemapi 416 * @stagemodelonly 417 * @since 10 418 */ 419 result: number; 420 } 421 422 /** 423 * Struct for a batch update operation. 424 * 425 * @interface UpdateOperation 426 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 427 * @systemapi 428 * @stagemodelonly 429 * @since 12 430 */ 431 interface UpdateOperation { 432 /** 433 * Indicates the data to update. 434 * 435 * @type { ValuesBucket } 436 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 437 * @systemapi 438 * @stagemodelonly 439 * @since 12 440 */ 441 values: ValuesBucket; 442 443 /** 444 * Indicates filter criteria. 445 * 446 * @type { dataSharePredicates.DataSharePredicates } 447 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 448 * @systemapi 449 * @stagemodelonly 450 * @since 12 451 */ 452 predicates: dataSharePredicates.DataSharePredicates; 453 } 454 455 /** 456 * Enumerates the data change types. 457 * 458 * @enum { number } 459 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 460 * @systemapi 461 * @stagemodelonly 462 * @since 12 463 */ 464 enum ChangeType { 465 /** 466 * Data inserted. 467 * 468 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 469 * @systemapi 470 * @stagemodelonly 471 * @since 12 472 */ 473 INSERT = 0, 474 475 /** 476 * Data deleted. 477 * 478 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 479 * @systemapi 480 * @stagemodelonly 481 * @since 12 482 */ 483 DELETE, 484 /** 485 * Data updated. 486 * 487 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 488 * @systemapi 489 * @stagemodelonly 490 * @since 12 491 */ 492 UPDATE 493 } 494 /** 495 * Enumerates the subscription types. 496 * 497 * @enum { number } 498 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 499 * @systemapi 500 * @stagemodelonly 501 * @since 12 502 */ 503 enum SubscriptionType { 504 /** 505 * Subscribe to the change of the data with the specified URI. 506 * 507 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 508 * @systemapi 509 * @stagemodelonly 510 * @since 12 511 */ 512 SUBSCRIPTION_TYPE_EXACT_URI = 0, 513 } 514 515 /** 516 * Struct for the data change. 517 * 518 * @interface ChangeInfo 519 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 520 * @systemapi 521 * @stagemodelonly 522 * @since 12 523 */ 524 interface ChangeInfo { 525 /** 526 * Type of the data change. 527 * 528 * @type { ChangeType } 529 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 530 * @systemapi 531 * @stagemodelonly 532 * @since 12 533 */ 534 type: ChangeType; 535 536 /** 537 * URI of the data changed. 538 * 539 * @type { string } 540 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 541 * @systemapi 542 * @stagemodelonly 543 * @since 12 544 */ 545 uri: string; 546 /** 547 * Data changed. 548 * 549 * @type { Array<ValuesBucket> } 550 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 551 * @systemapi 552 * @stagemodelonly 553 * @since 12 554 */ 555 values: Array<ValuesBucket>; 556 } 557 558 /** 559 * DataShareHelper 560 * 561 * @interface DataShareHelper 562 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 563 * @systemapi 564 * @stagemodelonly 565 * @since 9 566 */ 567 interface DataShareHelper { 568 /** 569 * Registers an observer to observe data specified by the given uri. 570 * 571 * @param { 'dataChange' } type - Type must be 'dataChange'. 572 * @param { string } uri - Indicates the path of the data to operate. 573 * @param { AsyncCallback<void> } callback - The callback of on. 574 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 575 * @systemapi 576 * @stagemodelonly 577 * @since 9 578 */ 579 /** 580 * Registers an observer to observe data specified by the given uri. 581 * 582 * @param { 'dataChange' } type - Type must be 'dataChange'. 583 * @param { string } uri - Indicates the path of the data to operate. 584 * @param { AsyncCallback<void> } callback - The callback of on. 585 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 586 * @throws { BusinessError } 202 - Not System Application. 587 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 588 * 2. Incorrect parameters types. 589 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 590 * @systemapi 591 * @stagemodelonly 592 * @since 12 593 */ 594 on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void; 595 596 /** 597 * Deregisters an observer used for monitoring data specified by the given uri. 598 * 599 * @param { 'dataChange' } type - Type must be 'dataChange'. 600 * @param { string } uri - Indicates the path of the data to operate. 601 * @param { AsyncCallback<void> } callback - The callback of off. 602 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 603 * @systemapi 604 * @stagemodelonly 605 * @since 9 606 */ 607 /** 608 * Deregisters an observer used for monitoring data specified by the given uri. 609 * 610 * @param { 'dataChange' } type - Type must be 'dataChange'. 611 * @param { string } uri - Indicates the path of the data to operate. 612 * @param { AsyncCallback<void> } callback - The callback of off. 613 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 614 * @throws { BusinessError } 202 - Not System Application. 615 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 616 * 2. Incorrect parameters types. 617 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 618 * @systemapi 619 * @stagemodelonly 620 * @since 12 621 */ 622 off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void; 623 /** 624 * Subscribes to the change of the data specified by the given URI. 625 * 626 * @param { 'dataChange' } event - Indicates the event type, which must be 'dataChange'. 627 * @param { SubscriptionType } type - Indicates the subscription type, which is defined in {@link SubscriptionType}. 628 * @param { string } uri - Indicates the path of the data to subscribe. 629 * @param { AsyncCallback<ChangeInfo> } callback - Indicates the callback used to return the data change. 630 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 631 * @throws { BusinessError } 202 - Not System Application. 632 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 633 * 2. Incorrect parameters types. 634 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 635 * @systemapi 636 * @stagemodelonly 637 * @since 12 638 */ 639 on(event: 'dataChange', type:SubscriptionType, uri: string, callback: AsyncCallback<ChangeInfo>): void; 640 641 /** 642 * Unsubscribes from the change of the data specified by the given URI. 643 * 644 * @param { 'dataChange' } event - Indicates the event type, which must be 'dataChange'. 645 * @param { SubscriptionType } type - Indicates the subscription type, which is defined in {@link SubscriptionType}. 646 * @param { string } uri - Indicates the path of the data to unsubscribe. 647 * @param { AsyncCallback<ChangeInfo> } callback - Indicates the callback to unsubscribe. 648 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 649 * 2. Incorrect parameters types. 650 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 651 * @throws { BusinessError } 202 - Not System Application. 652 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 653 * @systemapi 654 * @stagemodelonly 655 * @since 12 656 */ 657 off(event: 'dataChange', type:SubscriptionType, uri: string, callback?: AsyncCallback<ChangeInfo>): void; 658 659 /** 660 * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 661 * 662 * @param { string } uri - Indicates the uri to add. 663 * @param { string } subscriberId - The subscribe id to add.. 664 * @param { Template } template - The template to add. 665 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 666 * 2. Incorrect parameters types. 667 * @throws { BusinessError } 15700011 - The URI is not exist. 668 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 669 * @systemapi 670 * @stagemodelonly 671 * @since 10 672 */ 673 /** 674 * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 675 * 676 * @param { string } uri - Indicates the uri to add. 677 * @param { string } subscriberId - The subscribe id to add.. 678 * @param { Template } template - The template to add. 679 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 680 * 2. Incorrect parameters types. 681 * @throws { BusinessError } 15700011 - The URI is not exist. 682 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 683 * @throws { BusinessError } 202 - Not System Application. 684 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 685 * @systemapi 686 * @stagemodelonly 687 * @since 12 688 */ 689 addTemplate(uri: string, subscriberId: string, template: Template): void; 690 691 /** 692 * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 693 * 694 * @param { string } uri - Indicates the uri to delete. 695 * @param { string } subscriberId - The subscribe id. 696 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 697 * 2. Incorrect parameters types. 698 * @throws { BusinessError } 15700011 - The URI is not exist. 699 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 700 * @systemapi 701 * @stagemodelonly 702 * @since 10 703 */ 704 /** 705 * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 706 * 707 * @param { string } uri - Indicates the uri to delete. 708 * @param { string } subscriberId - The subscribe id. 709 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 710 * 2. Incorrect parameters types. 711 * @throws { BusinessError } 15700011 - The URI is not exist. 712 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 713 * @throws { BusinessError } 202 - Not System Application. 714 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 715 * @systemapi 716 * @stagemodelonly 717 * @since 12 718 */ 719 delTemplate(uri: string, subscriberId: string): void; 720 721 /** 722 * Registers observers to observe rdb data specified by the given uri and template. 723 * 724 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 725 * @param { Array<string> } uris - Indicates the paths of the data to operate. 726 * @param { TemplateId } templateId - The template of on. 727 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on. 728 * @returns { Array<OperationResult> } : The operation result. 729 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 730 * 2. Incorrect parameters types. 731 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 732 * @systemapi 733 * @stagemodelonly 734 * @since 10 735 */ 736 /** 737 * Registers observers to observe rdb data specified by the given uri and template. 738 * 739 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 740 * @param { Array<string> } uris - Indicates the paths of the data to operate. 741 * @param { TemplateId } templateId - The template of on. 742 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on. 743 * @returns { Array<OperationResult> } : The operation result. 744 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 745 * 2. Incorrect parameters types. 746 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 747 * @throws { BusinessError } 202 - Not System Application. 748 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 749 * @systemapi 750 * @stagemodelonly 751 * @since 12 752 */ 753 on( 754 type: 'rdbDataChange', 755 uris: Array<string>, 756 templateId: TemplateId, 757 callback: AsyncCallback<RdbDataChangeNode> 758 ): Array<OperationResult>; 759 760 /** 761 * Deregisters observers used for monitoring data specified by the given uri and template. 762 * 763 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 764 * @param { Array<string> } uris - Indicates the paths of the data to operate. 765 * @param { TemplateId } templateId - The template of off. 766 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off. 767 * @returns { Array<OperationResult> } : The operation result. 768 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 769 * 2. Incorrect parameters types. 770 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 771 * @systemapi 772 * @stagemodelonly 773 * @since 10 774 */ 775 /** 776 * Deregisters observers used for monitoring data specified by the given uri and template. 777 * 778 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 779 * @param { Array<string> } uris - Indicates the paths of the data to operate. 780 * @param { TemplateId } templateId - The template of off. 781 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off. 782 * @returns { Array<OperationResult> } : The operation result. 783 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 784 * 2. Incorrect parameters types. 785 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 786 * @throws { BusinessError } 202 - Not System Application. 787 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 788 * @systemapi 789 * @stagemodelonly 790 * @since 12 791 */ 792 off( 793 type: 'rdbDataChange', 794 uris: Array<string>, 795 templateId: TemplateId, 796 callback?: AsyncCallback<RdbDataChangeNode> 797 ): Array<OperationResult>; 798 799 /** 800 * Registers observers to observe published data specified by the given key and subscriberId. 801 * 802 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 803 * @param { Array<string> } uris - Indicates the uris of the data to operate. 804 * @param { string } subscriberId - The subscriberId of on. 805 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on. 806 * @returns { Array<OperationResult> } : The operation result. 807 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 808 * 2. Incorrect parameters types. 809 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 810 * @systemapi 811 * @stagemodelonly 812 * @since 10 813 */ 814 /** 815 * Registers observers to observe published data specified by the given key and subscriberId. 816 * 817 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 818 * @param { Array<string> } uris - Indicates the uris of the data to operate. 819 * @param { string } subscriberId - The subscriberId of on. 820 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on. 821 * @returns { Array<OperationResult> } : The operation result. 822 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 823 * 2. Incorrect parameters types. 824 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 825 * @throws { BusinessError } 202 - Not System Application. 826 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 827 * @systemapi 828 * @stagemodelonly 829 * @since 12 830 */ 831 on( 832 type: 'publishedDataChange', 833 uris: Array<string>, 834 subscriberId: string, 835 callback: AsyncCallback<PublishedDataChangeNode> 836 ): Array<OperationResult>; 837 838 /** 839 * Deregisters observers used for monitoring data specified by the given key and subscriberId. 840 * 841 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 842 * @param { Array<string> } uris - Indicates the uris of the data to operate. 843 * @param { string } subscriberId - The subscriberId of off. 844 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off. 845 * @returns { Array<OperationResult> } : The operation result. 846 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 847 * 2. Incorrect parameters types. 848 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 849 * @systemapi 850 * @stagemodelonly 851 * @since 10 852 */ 853 /** 854 * Deregisters observers used for monitoring data specified by the given key and subscriberId. 855 * 856 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 857 * @param { Array<string> } uris - Indicates the uris of the data to operate. 858 * @param { string } subscriberId - The subscriberId of off. 859 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off. 860 * @returns { Array<OperationResult> } : The operation result. 861 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 862 * 2. Incorrect parameters types. 863 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 864 * @throws { BusinessError } 202 - Not System Application. 865 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 866 * @systemapi 867 * @stagemodelonly 868 * @since 12 869 */ 870 off( 871 type: 'publishedDataChange', 872 uris: Array<string>, 873 subscriberId: string, 874 callback?: AsyncCallback<PublishedDataChangeNode> 875 ): Array<OperationResult>; 876 877 /** 878 * Update a single data into host data area. 879 * 880 * @param { Array<PublishedItem> } data - Indicates the data to publish. 881 * @param { string } bundleName - Indicates the bundleName of data to publish. 882 * @param { number } version - Indicates the version of data to publish, larger is newer. 883 * @param { AsyncCallback<Array<OperationResult>> } callback 884 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 885 * 2. Incorrect parameters types. 886 * @throws { BusinessError } 15700012 - The data area is not exist. 887 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 888 * @systemapi 889 * @stagemodelonly 890 * @since 10 891 */ 892 /** 893 * Update a single data into host data area. 894 * 895 * @param { Array<PublishedItem> } data - Indicates the data to publish. 896 * @param { string } bundleName - Indicates the bundleName of data to publish. 897 * @param { number } version - Indicates the version of data to publish, larger is newer. 898 * @param { AsyncCallback<Array<OperationResult>> } callback 899 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 900 * 2. Incorrect parameters types. 901 * @throws { BusinessError } 15700012 - The data area is not exist. 902 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 903 * @throws { BusinessError } 202 - Not System Application. 904 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 905 * @systemapi 906 * @stagemodelonly 907 * @since 12 908 */ 909 publish( 910 data: Array<PublishedItem>, 911 bundleName: string, 912 version: number, 913 callback: AsyncCallback<Array<OperationResult>> 914 ): void; 915 916 /** 917 * Update a single data into host data area. 918 * 919 * @param { Array<PublishedItem> } data - Indicates the data to publish. 920 * @param { string } bundleName - Indicates the bundleName of data to publish. 921 * @param { AsyncCallback<Array<OperationResult>> } callback 922 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 923 * 2. Incorrect parameters types. 924 * @throws { BusinessError } 15700012 - The data area is not exist. 925 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 926 * @systemapi 927 * @stagemodelonly 928 * @since 10 929 */ 930 /** 931 * Update a single data into host data area. 932 * 933 * @param { Array<PublishedItem> } data - Indicates the data to publish. 934 * @param { string } bundleName - Indicates the bundleName of data to publish. 935 * @param { AsyncCallback<Array<OperationResult>> } callback 936 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 937 * 2. Incorrect parameters types. 938 * @throws { BusinessError } 15700012 - The data area is not exist. 939 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 940 * @throws { BusinessError } 202 - Not System Application. 941 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 942 * @systemapi 943 * @stagemodelonly 944 * @since 12 945 */ 946 publish( 947 data: Array<PublishedItem>, 948 bundleName: string, 949 callback: AsyncCallback<Array<OperationResult>> 950 ): void; 951 952 /** 953 * Update a single data into host data area. 954 * 955 * @param { Array<PublishedItem> } data - Indicates the data to publish. 956 * @param { string } bundleName - Indicates the bundleName of data to publish. 957 * @param { number } version - Indicates the version of data to publish, larger is newer. 958 * @returns { Promise<Array<OperationResult>> } 959 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 960 * 2. Incorrect parameters types. 961 * @throws { BusinessError } 15700012 - The data area is not exist. 962 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 963 * @systemapi 964 * @stagemodelonly 965 * @since 10 966 */ 967 /** 968 * Update a single data into host data area. 969 * 970 * @param { Array<PublishedItem> } data - Indicates the data to publish. 971 * @param { string } bundleName - Indicates the bundleName of data to publish. 972 * @param { number } version - Indicates the version of data to publish, larger is newer. 973 * @returns { Promise<Array<OperationResult>> } 974 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 975 * 2. Incorrect parameters types. 976 * @throws { BusinessError } 15700012 - The data area is not exist. 977 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 978 * @throws { BusinessError } 202 - Not System Application. 979 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 980 * @systemapi 981 * @stagemodelonly 982 * @since 12 983 */ 984 publish(data: Array<PublishedItem>, bundleName: string, version?: number): Promise<Array<OperationResult>>; 985 986 /** 987 * Registers a one-time observer to observe data specified by the given uri and template. 988 * 989 * @param { string } bundleName - Indicates the bundleName of data to publish. 990 * @param { AsyncCallback<Array<PublishedItem>> } callback 991 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 992 * 2. Incorrect parameters types. 993 * @throws { BusinessError } 15700012 - The data area is not exist. 994 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 995 * @systemapi 996 * @stagemodelonly 997 * @since 10 998 */ 999 /** 1000 * Registers a one-time observer to observe data specified by the given uri and template. 1001 * 1002 * @param { string } bundleName - Indicates the bundleName of data to publish. 1003 * @param { AsyncCallback<Array<PublishedItem>> } callback 1004 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1005 * 2. Incorrect parameters types. 1006 * @throws { BusinessError } 15700012 - The data area is not exist. 1007 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1008 * @throws { BusinessError } 202 - Not System Application. 1009 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1010 * @systemapi 1011 * @stagemodelonly 1012 * @since 12 1013 */ 1014 getPublishedData(bundleName: string, callback: AsyncCallback<Array<PublishedItem>>): void; 1015 1016 /** 1017 * Registers a one-time observer to observe data specified by the given uri and template. 1018 * 1019 * @param { string } bundleName - Indicates the bundleName of data to publish. 1020 * @returns { Promise<Array<PublishedItem>> } 1021 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1022 * 2. Incorrect parameters types. 1023 * @throws { BusinessError } 15700012 - The data area is not exist. 1024 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1025 * @systemapi 1026 * @stagemodelonly 1027 * @since 10 1028 */ 1029 /** 1030 * Registers a one-time observer to observe data specified by the given uri and template. 1031 * 1032 * @param { string } bundleName - Indicates the bundleName of data to publish. 1033 * @returns { Promise<Array<PublishedItem>> } 1034 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1035 * 2. Incorrect parameters types. 1036 * @throws { BusinessError } 15700012 - The data area is not exist. 1037 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1038 * @throws { BusinessError } 202 - Not System Application. 1039 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1040 * @systemapi 1041 * @stagemodelonly 1042 * @since 12 1043 */ 1044 getPublishedData(bundleName: string): Promise<Array<PublishedItem>>; 1045 1046 /** 1047 * Inserts a single data record into the database. 1048 * 1049 * @param { string } uri - Indicates the path of the data to operate. 1050 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1051 * a blank row will be inserted. 1052 * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record. 1053 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1054 * 2. Incorrect parameters types. 1055 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1056 * @systemapi 1057 * @stagemodelonly 1058 * @since 9 1059 */ 1060 /** 1061 * Inserts a single data record into the database. 1062 * 1063 * @param { string } uri - Indicates the path of the data to operate. 1064 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1065 * a blank row will be inserted. 1066 * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record. 1067 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1068 * 2. Incorrect parameters types. 1069 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1070 * @throws { BusinessError } 202 - Not System Application. 1071 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1072 * @systemapi 1073 * @stagemodelonly 1074 * @since 12 1075 */ 1076 insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): void; 1077 1078 /** 1079 * Inserts a single data record into the database. 1080 * 1081 * @param { string } uri - Indicates the path of the data to operate. 1082 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1083 * a blank row will be inserted. 1084 * @returns { Promise<number> } {number}: the index of the inserted data record. 1085 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1086 * 2. Incorrect parameters types. 1087 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1088 * @systemapi 1089 * @stagemodelonly 1090 * @since 9 1091 */ 1092 /** 1093 * Inserts a single data record into the database. 1094 * 1095 * @param { string } uri - Indicates the path of the data to operate. 1096 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1097 * a blank row will be inserted. 1098 * @returns { Promise<number> } {number}: the index of the inserted data record. 1099 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1100 * 2. Incorrect parameters types. 1101 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1102 * @throws { BusinessError } 202 - Not System Application. 1103 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1104 * @systemapi 1105 * @stagemodelonly 1106 * @since 12 1107 */ 1108 insert(uri: string, value: ValuesBucket): Promise<number>; 1109 1110 /** 1111 * Deletes one or more data records from the database. 1112 * 1113 * @param { string } uri - Indicates the path of the data to operate. 1114 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1115 * You should define the processing logic when this parameter is null. 1116 * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted. 1117 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1118 * 2. Incorrect parameters types. 1119 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1120 * @systemapi 1121 * @stagemodelonly 1122 * @since 9 1123 */ 1124 /** 1125 * Deletes one or more data records from the database. 1126 * 1127 * @param { string } uri - Indicates the path of the data to operate. 1128 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1129 * You should define the processing logic when this parameter is null. 1130 * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted. 1131 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1132 * 2. Incorrect parameters types. 1133 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1134 * @throws { BusinessError } 202 - Not System Application. 1135 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1136 * @systemapi 1137 * @stagemodelonly 1138 * @since 12 1139 */ 1140 delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void; 1141 1142 /** 1143 * Deletes one or more data records from the database. 1144 * 1145 * @param { string } uri - Indicates the path of the data to operate. 1146 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1147 * You should define the processing logic when this parameter is null. 1148 * @returns { Promise<number> } {number}: the number of data records deleted. 1149 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1150 * 2. Incorrect parameters types. 1151 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1152 * @systemapi 1153 * @stagemodelonly 1154 * @since 9 1155 */ 1156 /** 1157 * Deletes one or more data records from the database. 1158 * 1159 * @param { string } uri - Indicates the path of the data to operate. 1160 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1161 * You should define the processing logic when this parameter is null. 1162 * @returns { Promise<number> } {number}: the number of data records deleted. 1163 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1164 * 2. Incorrect parameters types. 1165 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1166 * @throws { BusinessError } 202 - Not System Application. 1167 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1168 * @systemapi 1169 * @stagemodelonly 1170 * @since 12 1171 */ 1172 delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>; 1173 1174 /** 1175 * Queries data in the database. 1176 * 1177 * @param { string } uri - Indicates the path of data to query. 1178 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1179 * You should define the processing logic when this parameter is null. 1180 * @param { Array<string> } columns - Indicates the columns to query. 1181 * If this parameter is null, all columns are queried. 1182 * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result. 1183 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1184 * 2. Incorrect parameters types. 1185 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1186 * @systemapi 1187 * @stagemodelonly 1188 * @since 9 1189 */ 1190 /** 1191 * Queries data in the database. 1192 * 1193 * @param { string } uri - Indicates the path of data to query. 1194 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1195 * You should define the processing logic when this parameter is null. 1196 * @param { Array<string> } columns - Indicates the columns to query. 1197 * If this parameter is null, all columns are queried. 1198 * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result. 1199 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1200 * 2. Incorrect parameters types. 1201 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1202 * @throws { BusinessError } 202 - Not System Application. 1203 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1204 * @systemapi 1205 * @stagemodelonly 1206 * @since 12 1207 */ 1208 query( 1209 uri: string, 1210 predicates: dataSharePredicates.DataSharePredicates, 1211 columns: Array<string>, 1212 callback: AsyncCallback<DataShareResultSet> 1213 ): void; 1214 1215 /** 1216 * Queries data in the database. 1217 * 1218 * @param { string } uri - Indicates the path of data to query. 1219 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1220 * You should define the processing logic when this parameter is null. 1221 * @param { Array<string> } columns - Indicates the columns to query. 1222 * If this parameter is null, all columns are queried. 1223 * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result. 1224 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1225 * 2. Incorrect parameters types. 1226 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1227 * @systemapi 1228 * @stagemodelonly 1229 * @since 9 1230 */ 1231 /** 1232 * Queries data in the database. 1233 * 1234 * @param { string } uri - Indicates the path of data to query. 1235 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1236 * You should define the processing logic when this parameter is null. 1237 * @param { Array<string> } columns - Indicates the columns to query. 1238 * If this parameter is null, all columns are queried. 1239 * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result. 1240 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1241 * 2. Incorrect parameters types. 1242 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1243 * @throws { BusinessError } 202 - Not System Application. 1244 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1245 * @systemapi 1246 * @stagemodelonly 1247 * @since 12 1248 */ 1249 query( 1250 uri: string, 1251 predicates: dataSharePredicates.DataSharePredicates, 1252 columns: Array<string> 1253 ): Promise<DataShareResultSet>; 1254 1255 /** 1256 * Updates data records in the database. 1257 * 1258 * @param { string } uri - Indicates the path of data to update. 1259 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1260 * You should define the processing logic when this parameter is null. 1261 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1262 * @param { AsyncCallback<number> } callback - {number}: the number of data records updated. 1263 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1264 * 2. Incorrect parameters types. 1265 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1266 * @systemapi 1267 * @stagemodelonly 1268 * @since 9 1269 */ 1270 /** 1271 * Updates data records in the database. 1272 * 1273 * @param { string } uri - Indicates the path of data to update. 1274 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1275 * You should define the processing logic when this parameter is null. 1276 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1277 * @param { AsyncCallback<number> } callback - {number}: the number of data records updated. 1278 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1279 * 2. Incorrect parameters types. 1280 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1281 * @throws { BusinessError } 202 - Not System Application. 1282 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1283 * @systemapi 1284 * @stagemodelonly 1285 * @since 12 1286 */ 1287 update( 1288 uri: string, 1289 predicates: dataSharePredicates.DataSharePredicates, 1290 value: ValuesBucket, 1291 callback: AsyncCallback<number> 1292 ): void; 1293 1294 /** 1295 * Updates data records in the database. 1296 * 1297 * @param { string } uri - Indicates the path of data to update. 1298 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1299 * You should define the processing logic when this parameter is null. 1300 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1301 * @returns { Promise<number> } {number}: the number of data records updated. 1302 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1303 * 2. Incorrect parameters types. 1304 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1305 * @systemapi 1306 * @stagemodelonly 1307 * @since 9 1308 */ 1309 /** 1310 * Updates data records in the database. 1311 * 1312 * @param { string } uri - Indicates the path of data to update. 1313 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1314 * You should define the processing logic when this parameter is null. 1315 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1316 * @returns { Promise<number> } {number}: the number of data records updated. 1317 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1318 * 2. Incorrect parameters types. 1319 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1320 * @throws { BusinessError } 202 - Not System Application. 1321 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1322 * @systemapi 1323 * @stagemodelonly 1324 * @since 12 1325 */ 1326 update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise<number>; 1327 1328 /** 1329 * Updates data records in the database. 1330 * 1331 * @param { Record<string, Array<UpdateOperation>> } operations - Indicates the data to update. 1332 * @returns {Promise<Record<string, Array<number>>>} {Record<string, Array<number>>}: The result set of batch operations. 1333 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1334 * 2. Incorrect parameters types. 1335 * @throws { BusinessError } 15700000 - Inner error. 1336 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1337 * @throws { BusinessError } 202 - Not System Application. 1338 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1339 * @systemapi 1340 * @stagemodelonly 1341 * @since 12 1342 */ 1343 batchUpdate(operations: Record<string, Array<UpdateOperation>>): Promise<Record<string, Array<number>>>; 1344 1345 /** 1346 * Inserts multiple data records into the database. 1347 * 1348 * @param { string } uri - Indicates the path of the data to operate. 1349 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1350 * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted. 1351 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1352 * 2. Incorrect parameters types. 1353 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1354 * @systemapi 1355 * @stagemodelonly 1356 * @since 9 1357 */ 1358 /** 1359 * Inserts multiple data records into the database. 1360 * 1361 * @param { string } uri - Indicates the path of the data to operate. 1362 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1363 * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted. 1364 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1365 * 2. Incorrect parameters types. 1366 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1367 * @throws { BusinessError } 202 - Not System Application. 1368 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1369 * @systemapi 1370 * @stagemodelonly 1371 * @since 12 1372 */ 1373 batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void; 1374 1375 /** 1376 * Inserts multiple data records into the database. 1377 * 1378 * @param { string } uri - Indicates the path of the data to operate. 1379 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1380 * @returns { Promise<number> } {number}: the number of data records inserted. 1381 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1382 * 2. Incorrect parameters types. 1383 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1384 * @systemapi 1385 * @stagemodelonly 1386 * @since 9 1387 */ 1388 /** 1389 * Inserts multiple data records into the database. 1390 * 1391 * @param { string } uri - Indicates the path of the data to operate. 1392 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1393 * @returns { Promise<number> } {number}: the number of data records inserted. 1394 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1395 * 2. Incorrect parameters types. 1396 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1397 * @throws { BusinessError } 202 - Not System Application. 1398 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1399 * @systemapi 1400 * @stagemodelonly 1401 * @since 12 1402 */ 1403 batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number>; 1404 1405 /** 1406 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1407 * A normalized uri can be used across devices, persisted, backed up, and restored. 1408 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1409 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1410 * to convert it to a denormalized uri that can be used only in the current environment. 1411 * 1412 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1413 * @param { AsyncCallback<string> } callback - {string}: the normalized Uri, 1414 * if the DataShare supports uri normalization. 1415 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1416 * @systemapi 1417 * @stagemodelonly 1418 * @since 9 1419 */ 1420 /** 1421 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1422 * A normalized uri can be used across devices, persisted, backed up, and restored. 1423 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1424 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1425 * to convert it to a denormalized uri that can be used only in the current environment. 1426 * 1427 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1428 * @param { AsyncCallback<string> } callback - {string}: the normalized Uri, 1429 * if the DataShare supports uri normalization. 1430 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1431 * @throws { BusinessError } 202 - Not System Application. 1432 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1433 * 2. Incorrect parameters types. 1434 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1435 * @systemapi 1436 * @stagemodelonly 1437 * @since 12 1438 */ 1439 normalizeUri(uri: string, callback: AsyncCallback<string>): void; 1440 1441 /** 1442 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1443 * A normalized uri can be used across devices, persisted, backed up, and restored. 1444 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1445 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1446 * to convert it to a denormalized uri that can be used only in the current environment. 1447 * 1448 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1449 * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization; 1450 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1451 * @systemapi 1452 * @stagemodelonly 1453 * @since 9 1454 */ 1455 /** 1456 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1457 * A normalized uri can be used across devices, persisted, backed up, and restored. 1458 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1459 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1460 * to convert it to a denormalized uri that can be used only in the current environment. 1461 * 1462 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1463 * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization; 1464 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1465 * @throws { BusinessError } 202 - Not System Application. 1466 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1467 * 2. Incorrect parameters types. 1468 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1469 * @systemapi 1470 * @stagemodelonly 1471 * @since 12 1472 */ 1473 normalizeUri(uri: string): Promise<string>; 1474 1475 /** 1476 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1477 * 1478 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1479 * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if 1480 * the denormalization is successful; returns the original {@code Uri} passed to this method if 1481 * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri} 1482 * cannot be found in the current environment. 1483 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1484 * @systemapi 1485 * @stagemodelonly 1486 * @since 9 1487 */ 1488 /** 1489 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1490 * 1491 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1492 * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if 1493 * the denormalization is successful; returns the original {@code Uri} passed to this method if 1494 * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri} 1495 * cannot be found in the current environment. 1496 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1497 * @throws { BusinessError } 202 - Not System Application. 1498 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1499 * 2. Incorrect parameters types. 1500 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1501 * @systemapi 1502 * @stagemodelonly 1503 * @since 12 1504 */ 1505 denormalizeUri(uri: string, callback: AsyncCallback<string>): void; 1506 1507 /** 1508 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1509 * 1510 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1511 * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization 1512 * is successful; returns the original {@code Uri} passed to this method if there is nothing to do; 1513 * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the 1514 * current environment. 1515 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1516 * @systemapi 1517 * @stagemodelonly 1518 * @since 9 1519 */ 1520 /** 1521 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1522 * 1523 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1524 * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization 1525 * is successful; returns the original {@code Uri} passed to this method if there is nothing to do; 1526 * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the 1527 * current environment. 1528 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1529 * @throws { BusinessError } 202 - Not System Application. 1530 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1531 * 2. Incorrect parameters types. 1532 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1533 * @systemapi 1534 * @stagemodelonly 1535 * @since 12 1536 */ 1537 denormalizeUri(uri: string): Promise<string>; 1538 1539 /** 1540 * Notifies the registered observers of a change to the data resource specified by Uri. 1541 * 1542 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1543 * @param { AsyncCallback<void> } callback - The callback of notifyChange. 1544 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1545 * @systemapi 1546 * @stagemodelonly 1547 * @since 9 1548 */ 1549 /** 1550 * Notifies the registered observers of a change to the data resource specified by Uri. 1551 * 1552 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1553 * @param { AsyncCallback<void> } callback - The callback of notifyChange. 1554 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1555 * @throws { BusinessError } 202 - Not System Application. 1556 * @throws { BusinessError } 401 - Parameter error.Mandatory parameters are left unspecified. 1557 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1558 * @systemapi 1559 * @stagemodelonly 1560 * @since 12 1561 */ 1562 notifyChange(uri: string, callback: AsyncCallback<void>): void; 1563 1564 /** 1565 * Notifies the registered observers of a change to the data resource specified by Uri. 1566 * 1567 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1568 * @returns { Promise<void> } The promise returned by the function. 1569 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1570 * @systemapi 1571 * @stagemodelonly 1572 * @since 9 1573 */ 1574 /** 1575 * Notifies the registered observers of a change to the data resource specified by Uri. 1576 * 1577 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1578 * @returns { Promise<void> } The promise returned by the function. 1579 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1580 * @throws { BusinessError } 202 - Not System Application. 1581 * @throws { BusinessError } 401 - Parameter error.Mandatory parameters are left unspecified. 1582 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1583 * @systemapi 1584 * @stagemodelonly 1585 * @since 12 1586 */ 1587 notifyChange(uri: string): Promise<void>; 1588 1589 /** 1590 * Notifies the registered observers of the data change. 1591 * 1592 * @param { ChangeInfo } data - Indicates the data change information. 1593 * @returns { Promise<void> } Promise that returns no value. 1594 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1595 * @throws { BusinessError } 202 - Not System Application. 1596 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1597 * 2. Incorrect parameters types. 1598 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1599 * @systemapi 1600 * @stagemodelonly 1601 * @since 12 1602 */ 1603 notifyChange(data: ChangeInfo): Promise<void>; 1604 1605 /** 1606 * Close the connection between datashare and extension. 1607 * 1608 * @returns { Promise<void> } The promise returned by the function. 1609 * @throws { BusinessError } 15700000 - Inner error. 1610 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1611 * @systemapi 1612 * @stagemodelonly 1613 * @since 12 1614 */ 1615 close(): Promise<void>; 1616 } 1617} 1618 1619export default dataShare; 1620