• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type { AsyncCallback } from './@ohos.base';
17import Context from './application/Context';
18import DataShareResultSet from './@ohos.data.DataShareResultSet';
19import dataSharePredicates from './@ohos.data.dataSharePredicates';
20import { ValuesBucket } from './@ohos.data.ValuesBucket';
21
22/**
23 * This module provides the dataShare capability for consumer.
24 *
25 * @namespace dataShare
26 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
27 * @systemapi
28 * @StageModelOnly
29 * @since 9
30 */
31declare namespace dataShare {
32  /**
33   * Manages create datashare helper options.
34   *
35   * @interface DataShareHelperOptions
36   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
37   * @systemapi
38   * @StageModelOnly
39   * @since 10
40   */
41  interface DataShareHelperOptions {
42    /**
43     * Specifies whether the {@link DataShareHelper} in proxy mode.
44     * If value is true, the {@link DataShareHelper} to be created is in proxy mode, and all operations will not open provider APP as possible
45     *
46     * @default false
47     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
48     * @systemapi
49     * @StageModelOnly
50     * @since 10
51     */
52    isProxy?: boolean;
53  }
54
55  /**
56   * Obtains the dataShareHelper.
57   *
58   * @param { Context } context - Indicates the application context.
59   * @param { string } uri - Indicates the path of the file to open.
60   * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer.
61   * @throws { BusinessError } 401 - Parameter error.
62   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
63   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
64   * @systemapi
65   * @StageModelOnly
66   * @since 9
67   */
68  function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<DataShareHelper>): void;
69  /**
70   * Obtains the dataShareHelper.
71   *
72   * @param { Context } context - Indicates the application context.
73   * @param { string } uri - Indicates the path of the file to open.
74   * @param { DataShareHelperOptions } options - Indicates the optional config.
75   * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer.
76   * @throws { BusinessError } 401 - Parameter error.
77   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
78   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
79   * @systemapi
80   * @StageModelOnly
81   * @since 10
82   */
83  function createDataShareHelper(
84    context: Context,
85    uri: string,
86    options: DataShareHelperOptions,
87    callback: AsyncCallback<DataShareHelper>
88  ): void;
89
90  /**
91   * Obtains the dataShareHelper.
92   *
93   * @param { Context } context - Indicates the application context.
94   * @param { string } uri - Indicates the path of the file to open.
95   * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer.
96   * @throws { BusinessError } 401 - Parameter error.
97   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
98   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
99   * @systemapi
100   * @StageModelOnly
101   * @since 9
102   */
103  /**
104   * Obtains the dataShareHelper.
105   *
106   * @param { Context } context - Indicates the application context.
107   * @param { string } uri - Indicates the path of the file to open.
108   * @param { DataShareHelperOptions } options - Indicates the optional config.
109   * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer.
110   * @throws { BusinessError } 401 - Parameter error.
111   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
112   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
113   * @systemapi
114   * @StageModelOnly
115   * @since 10
116   */
117  function createDataShareHelper(
118    context: Context,
119    uri: string,
120    options?: DataShareHelperOptions
121  ): Promise<DataShareHelper>;
122
123  /**
124   * Specifies the {@link Template} id structure.
125   * A template is marked by the template id. Note that the template id is auto generated in {@link DataShareHelper#addTemplate}.
126   * After {@link DataShareHelper#addTemplate}, can use the template id to direct a template.
127   *
128   * @interface TemplateId
129   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
130   * @systemapi
131   * @StageModelOnly
132   * @since 10
133   */
134  interface TemplateId {
135    /**
136     * Specifies the id of subscriber, who process the callback
137     * Same as subscriberId in {@link DataShareHelper#addTemplate}
138     *
139     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
140     * @systemapi
141     * @StageModelOnly
142     * @since 10
143     */
144    subscriberId: string;
145    /**
146     * Specifies the bundleName of template owner, who create the template
147     * Same as the caller's bundleName of {@link DataShareHelper#addTemplate}
148     *
149     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
150     * @systemapi
151     * @StageModelOnly
152     * @since 10
153     */
154    bundleNameOfOwner: string;
155  }
156
157  /**
158   * Specifies the published item structure.
159   *
160   * @interface PublishedItem
161   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
162   * @systemapi
163   * @StageModelOnly
164   * @since 10
165   */
166  interface PublishedItem {
167    /**
168     * Specifies the key of the published data
169     *
170     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
171     * @systemapi
172     * @StageModelOnly
173     * @since 10
174     */
175    key: string;
176    /**
177     * Specifies the published data
178     * If the data is large, use ArrayBuffer.
179     *
180     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
181     * @systemapi
182     * @StageModelOnly
183     * @since 10
184     */
185    data: string | ArrayBuffer;
186    /**
187     * Specifies the subscriber id
188     *
189     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
190     * @systemapi
191     * @StageModelOnly
192     * @since 10
193     */
194    subscriberId: string;
195  }
196
197  /**
198   * Specifies the change node structure of rdb store data in callback.
199   *
200   * @interface RdbDataChangeNode
201   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
202   * @systemapi
203   * @StageModelOnly
204   * @since 10
205   */
206  interface RdbDataChangeNode {
207    /**
208     * Specifies the uri of the callback.
209     *
210     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
211     * @systemapi
212     * @StageModelOnly
213     * @since 10
214     */
215    uri: string;
216    /**
217     * Specifies the templateId of the callback.
218     *
219     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
220     * @systemapi
221     * @StageModelOnly
222     * @since 10
223     */
224    templateId: TemplateId;
225    /**
226     * Specifies the datas of the callback.
227     * every node is a json, json's key is [key of {@link Template#predicates}
228     * and value is the query result from rdb store query by value of{@link Template#predicates}].
229     *
230     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
231     * @systemapi
232     * @StageModelOnly
233     * @since 10
234     */
235    data: Array<string>;
236  }
237
238  /**
239   * Specifies the change node structure of published data in callback.
240   *
241   * @interface PublishedDataChangeNode
242   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
243   * @systemapi
244   * @StageModelOnly
245   * @since 10
246   */
247  interface PublishedDataChangeNode {
248    /**
249     * Specifies the bundleName of the callback.
250     *
251     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
252     * @systemapi
253     * @StageModelOnly
254     * @since 10
255     */
256    bundleName: string;
257    /**
258     * Specifies the datas of the callback.
259     *
260     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
261     * @systemapi
262     * @StageModelOnly
263     * @since 10
264     */
265    data: Array<PublishedItem>;
266  }
267
268  /**
269   * Specifies the template structure in subscribe.
270   *
271   * @interface Template
272   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
273   * @systemapi
274   * @StageModelOnly
275   * @since 10
276   */
277  interface Template {
278    /**
279     * Specifies the predicates of the template.
280     * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}
281     * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data.
282     *
283     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
284     * @systemapi
285     * @StageModelOnly
286     * @since 10
287     */
288    predicates: { [key: string]: string };
289
290    /**
291     * Specifies the scheduler sql of the template.
292     * When modify the subscribed uri's data, scheduler is auto called.
293     *
294     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
295     * @systemapi
296     * @StageModelOnly
297     * @since 10
298     */
299    scheduler: string;
300  }
301  /**
302   * Specifies the operation result structure.
303   *
304   * @interface OperationResult
305   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
306   * @systemapi
307   * @StageModelOnly
308   * @since 10
309   */
310  interface OperationResult {
311    /**
312     * Specifies the key of the operation result.
313     *
314     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
315     * @systemapi
316     * @StageModelOnly
317     * @since 10
318     */
319    key: string;
320
321    /**
322     * Specifies the operation result.
323     *
324     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
325     * @systemapi
326     * @StageModelOnly
327     * @since 10
328     */
329    result: number;
330  }
331
332  /**
333   * DataShareHelper
334   *
335   * @interface DataShareHelper
336   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
337   * @systemapi
338   * @StageModelOnly
339   * @since 9
340   */
341  interface DataShareHelper {
342    /**
343     * Registers an observer to observe data specified by the given uri.
344     *
345     * @param { 'dataChange' } type - Type must be 'dataChange'.
346     * @param { string } uri - Indicates the path of the data to operate.
347     * @param { AsyncCallback<void> } callback - The callback of on.
348     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
349     * @systemapi
350     * @StageModelOnly
351     * @since 9
352     */
353    on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void;
354
355    /**
356     * Deregisters an observer used for monitoring data specified by the given uri.
357     *
358     * @param { 'dataChange' } type - Type must be 'dataChange'.
359     * @param { string } uri - Indicates the path of the data to operate.
360     * @param { AsyncCallback<void> } callback - The callback of off.
361     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
362     * @systemapi
363     * @StageModelOnly
364     * @since 9
365     */
366    off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void;
367
368    /**
369     * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}.
370     *
371     * @param { string } uri - Indicates the uri to add.
372     * @param { string } subscriberId - The subscribe id to add..
373     * @param { Template } template - The template to add.
374     * @throws { BusinessError } 401 - Parameter error.
375     * @throws { BusinessError } 15700011 - The uri is not exist.
376     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
377     * @systemapi
378     * @StageModelOnly
379     * @since 10
380     */
381    addTemplate(uri: string, subscriberId: string, template: Template): void;
382
383    /**
384     * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}.
385     *
386     * @param { string } uri - Indicates the uri to delete.
387     * @param { string } subscriberId - The subscribe id.
388     * @throws { BusinessError } 401 - Parameter error.
389     * @throws { BusinessError } 15700011 - The uri is not exist.
390     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
391     * @systemapi
392     * @StageModelOnly
393     * @since 10
394     */
395    delTemplate(uri: string, subscriberId: string): void;
396
397    /**
398     * Registers observers to observe rdb data specified by the given uri and template.
399     *
400     * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'.
401     * @param { Array<string> } uris - Indicates the paths of the data to operate.
402     * @param { TemplateId } templateId - The template of on.
403     * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on.
404     * @returns { Array<OperationResult> } : The operation result.
405     * @throws { BusinessError } 401 - Parameter error.
406     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
407     * @systemapi
408     * @StageModelOnly
409     * @since 10
410     */
411    on(
412      type: 'rdbDataChange',
413      uris: Array<string>,
414      templateId: TemplateId,
415      callback: AsyncCallback<RdbDataChangeNode>
416    ): Array<OperationResult>;
417
418    /**
419     * Deregisters observers used for monitoring data specified by the given uri and template.
420     *
421     * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'.
422     * @param { Array<string> } uris - Indicates the paths of the data to operate.
423     * @param { TemplateId } templateId - The template of off.
424     * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off.
425     * @returns { Array<OperationResult> } : The operation result.
426     * @throws { BusinessError } 401 - Parameter error.
427     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
428     * @systemapi
429     * @StageModelOnly
430     * @since 10
431     */
432    off(
433      type: 'rdbDataChange',
434      uris: Array<string>,
435      templateId: TemplateId,
436      callback?: AsyncCallback<RdbDataChangeNode>
437    ): Array<OperationResult>;
438
439    /**
440     * Registers observers to observe published data specified by the given key and subscriberId.
441     *
442     * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'.
443     * @param { Array<string> } uris - Indicates the uris of the data to operate.
444     * @param { string } subscriberId - The subscriberId of on.
445     * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on.
446     * @returns { Array<OperationResult> } : The operation result.
447     * @throws { BusinessError } 401 - Parameter error.
448     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
449     * @systemapi
450     * @StageModelOnly
451     * @since 10
452     */
453    on(
454      type: 'publishedDataChange',
455      uris: Array<string>,
456      subscriberId: string,
457      callback: AsyncCallback<PublishedDataChangeNode>
458    ): Array<OperationResult>;
459
460    /**
461     * Deregisters observers used for monitoring data specified by the given key and subscriberId.
462     *
463     * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'.
464     * @param { Array<string> } uris - Indicates the uris of the data to operate.
465     * @param { string } subscriberId - The template of off.
466     * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off.
467     * @returns { Array<OperationResult> } : The operation result.
468     * @throws { BusinessError } 401 - Parameter error.
469     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
470     * @systemapi
471     * @StageModelOnly
472     * @since 10
473     */
474    off(
475      type: 'publishedDataChange',
476      uris: Array<string>,
477      subscriberId: string,
478      callback?: AsyncCallback<PublishedDataChangeNode>
479    ): Array<OperationResult>;
480
481    /**
482     * Update a single data into host data area.
483     *
484     * @param { Array<PublishedItem> } data - Indicates the data to publish.
485     * @param { string } bundleName - Indicates the bundleName of data to publish.
486     * @param { number } version - Indicates the version of data to publish, larger is newer.
487     * @param { AsyncCallback<Array<OperationResult>> } callback
488     * @throws { BusinessError } 401 - Parameter error.
489     * @throws { BusinessError } 15700012 - The data area is not exist.
490     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
491     * @systemapi
492     * @StageModelOnly
493     * @since 10
494     */
495    publish(
496      data: Array<PublishedItem>,
497      bundleName: string,
498      version: number,
499      callback: AsyncCallback<Array<OperationResult>>
500    ): void;
501
502    /**
503     * Update a single data into host data area.
504     *
505     * @param { Array<PublishedItem> } data - Indicates the data to publish.
506     * @param { string } bundleName - Indicates the bundleName of data to publish.
507     * @param { AsyncCallback<Array<OperationResult>> } callback
508     * @throws { BusinessError } 401 - Parameter error.
509     * @throws { BusinessError } 15700012 - The data area is not exist.
510     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
511     * @systemapi
512     * @StageModelOnly
513     * @since 10
514     */
515    publish(
516      data: Array<PublishedItem>,
517      bundleName: string,
518      callback: AsyncCallback<Array<OperationResult>>
519    ): void;
520
521    /**
522     * Update a single data into host data area.
523     *
524     * @param { Array<PublishedItem> } data - Indicates the data to publish.
525     * @param { string } bundleName - Indicates the bundleName of data to publish.
526     * @param { number } version - Indicates the version of data to publish, larger is newer.
527     * @returns { Promise<Array<OperationResult>> }
528     * @throws { BusinessError } 401 - Parameter error.
529     * @throws { BusinessError } 15700012 - The data area is not exist.
530     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
531     * @systemapi
532     * @StageModelOnly
533     * @since 10
534     */
535    publish(data: Array<PublishedItem>, bundleName: string, version?: number): Promise<Array<OperationResult>>;
536
537    /**
538     * Registers a one-time observer to observe data specified by the given uri and template.
539     *
540     * @param { string } bundleName - Indicates the bundleName of data to publish.
541     * @param { AsyncCallback<Array<PublishedItem>> } callback
542     * @throws { BusinessError } 401 - Parameter error.
543     * @throws { BusinessError } 15700012 - The data area is not exist.
544     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
545     * @systemapi
546     * @StageModelOnly
547     * @since 10
548     */
549    getPublishedData(bundleName: string, callback: AsyncCallback<Array<PublishedItem>>): void;
550
551    /**
552     * Registers a one-time observer to observe data specified by the given uri and template.
553     *
554     * @param { string } bundleName - Indicates the bundleName of data to publish.
555     * @returns { Promise<Array<PublishedItem>> }
556     * @throws { BusinessError } 401 - Parameter error.
557     * @throws { BusinessError } 15700012 - The data area is not exist.
558     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
559     * @systemapi
560     * @StageModelOnly
561     * @since 10
562     */
563    getPublishedData(bundleName: string): Promise<Array<PublishedItem>>;
564
565    /**
566     * Inserts a single data record into the database.
567     *
568     * @param { string } uri - Indicates the path of the data to operate.
569     * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null,
570     * a blank row will be inserted.
571     * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record.
572     * @throws { BusinessError } 401 - Parameter error.
573     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
574     * @systemapi
575     * @StageModelOnly
576     * @since 9
577     */
578    insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): void;
579
580    /**
581     * Inserts a single data record into the database.
582     *
583     * @param { string } uri - Indicates the path of the data to operate.
584     * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null,
585     * a blank row will be inserted.
586     * @returns { Promise<number> } {number}: the index of the inserted data record.
587     * @throws { BusinessError } 401 - Parameter error.
588     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
589     * @systemapi
590     * @StageModelOnly
591     * @since 9
592     */
593    insert(uri: string, value: ValuesBucket): Promise<number>;
594
595    /**
596     * Deletes one or more data records from the database.
597     *
598     * @param { string } uri - Indicates the path of the data to operate.
599     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
600     * You should define the processing logic when this parameter is null.
601     * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted.
602     * @throws { BusinessError } 401 - Parameter error.
603     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
604     * @systemapi
605     * @StageModelOnly
606     * @since 9
607     */
608    delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void;
609
610    /**
611     * Deletes one or more data records from the database.
612     *
613     * @param { string } uri - Indicates the path of the data to operate.
614     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
615     * You should define the processing logic when this parameter is null.
616     * @returns { Promise<number> } {number}: the number of data records deleted.
617     * @throws { BusinessError } 401 - Parameter error.
618     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
619     * @systemapi
620     * @StageModelOnly
621     * @since 9
622     */
623    delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>;
624
625    /**
626     * Queries data in the database.
627     *
628     * @param { string } uri - Indicates the path of data to query.
629     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
630     * You should define the processing logic when this parameter is null.
631     * @param { Array<string> } columns - Indicates the columns to query.
632     * If this parameter is null, all columns are queried.
633     * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result.
634     * @throws { BusinessError } 401 - Parameter error.
635     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
636     * @systemapi
637     * @StageModelOnly
638     * @since 9
639     */
640    query(
641      uri: string,
642      predicates: dataSharePredicates.DataSharePredicates,
643      columns: Array<string>,
644      callback: AsyncCallback<DataShareResultSet>
645    ): void;
646
647    /**
648     * Queries data in the database.
649     *
650     * @param { string } uri - Indicates the path of data to query.
651     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
652     * You should define the processing logic when this parameter is null.
653     * @param { Array<string> } columns - Indicates the columns to query.
654     * If this parameter is null, all columns are queried.
655     * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result.
656     * @throws { BusinessError } 401 - Parameter error.
657     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
658     * @systemapi
659     * @StageModelOnly
660     * @since 9
661     */
662    query(
663      uri: string,
664      predicates: dataSharePredicates.DataSharePredicates,
665      columns: Array<string>
666    ): Promise<DataShareResultSet>;
667
668    /**
669     * Updates data records in the database.
670     *
671     * @param { string } uri - Indicates the path of data to update.
672     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
673     * You should define the processing logic when this parameter is null.
674     * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null.
675     * @param { AsyncCallback<number> } callback - {number}: the number of data records updated.
676     * @throws { BusinessError } 401 - Parameter error.
677     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
678     * @systemapi
679     * @StageModelOnly
680     * @since 9
681     */
682    update(
683      uri: string,
684      predicates: dataSharePredicates.DataSharePredicates,
685      value: ValuesBucket,
686      callback: AsyncCallback<number>
687    ): void;
688
689    /**
690     * Updates data records in the database.
691     *
692     * @param { string } uri - Indicates the path of data to update.
693     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
694     * You should define the processing logic when this parameter is null.
695     * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null.
696     * @returns { Promise<number> } {number}: the number of data records updated.
697     * @throws { BusinessError } 401 - Parameter error.
698     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
699     * @systemapi
700     * @StageModelOnly
701     * @since 9
702     */
703    update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise<number>;
704
705    /**
706     * Inserts multiple data records into the database.
707     *
708     * @param { string } uri - Indicates the path of the data to operate.
709     * @param { Array<ValuesBucket> } values - Indicates the data records to insert.
710     * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted.
711     * @throws { BusinessError } 401 - Parameter error.
712     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
713     * @systemapi
714     * @StageModelOnly
715     * @since 9
716     */
717    batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void;
718
719    /**
720     * Inserts multiple data records into the database.
721     *
722     * @param { string } uri - Indicates the path of the data to operate.
723     * @param { Array<ValuesBucket> } values - Indicates the data records to insert.
724     * @returns { Promise<number> } {number}: the number of data records inserted.
725     * @throws { BusinessError } 401 - Parameter error.
726     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
727     * @systemapi
728     * @StageModelOnly
729     * @since 9
730     */
731    batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number>;
732
733    /**
734     * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}.
735     * A normalized uri can be used across devices, persisted, backed up, and restored.
736     * <p>To transfer a normalized uri from another environment to the current environment, you should call this
737     * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)}
738     * to convert it to a denormalized uri that can be used only in the current environment.
739     *
740     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize.
741     * @param { AsyncCallback<string> } callback - {string}: the normalized Uri,
742     * if the DataShare supports uri normalization.
743     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
744     * @systemapi
745     * @StageModelOnly
746     * @since 9
747     */
748    normalizeUri(uri: string, callback: AsyncCallback<string>): void;
749
750    /**
751     * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}.
752     * A normalized uri can be used across devices, persisted, backed up, and restored.
753     * <p>To transfer a normalized uri from another environment to the current environment, you should call this
754     * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)}
755     * to convert it to a denormalized uri that can be used only in the current environment.
756     *
757     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize.
758     * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization;
759     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
760     * @systemapi
761     * @StageModelOnly
762     * @since 9
763     */
764    normalizeUri(uri: string): Promise<string>;
765
766    /**
767     * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one.
768     *
769     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize.
770     * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if
771     * the denormalization is successful; returns the original {@code Uri} passed to this method if
772     * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri}
773     * cannot be found in the current environment.
774     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
775     * @systemapi
776     * @StageModelOnly
777     * @since 9
778     */
779    denormalizeUri(uri: string, callback: AsyncCallback<string>): void;
780
781    /**
782     * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one.
783     *
784     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize.
785     * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization
786     * is successful; returns the original {@code Uri} passed to this method if there is nothing to do;
787     * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the
788     * current environment.
789     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
790     * @systemapi
791     * @StageModelOnly
792     * @since 9
793     */
794    denormalizeUri(uri: string): Promise<string>;
795
796    /**
797     * Notifies the registered observers of a change to the data resource specified by Uri.
798     *
799     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange.
800     * @param { AsyncCallback<void> } callback - The callback of notifyChange.
801     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
802     * @systemapi
803     * @StageModelOnly
804     * @since 9
805     */
806    notifyChange(uri: string, callback: AsyncCallback<void>): void;
807
808    /**
809     * Notifies the registered observers of a change to the data resource specified by Uri.
810     *
811     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange.
812     * @returns { Promise<void> } The promise returned by the function.
813     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
814     * @systemapi
815     * @StageModelOnly
816     * @since 9
817     */
818    notifyChange(uri: string): Promise<void>;
819  }
820}
821
822export default dataShare;
823