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