1# @ohos.data.cloudData (端云服务)(系统接口)
2
3端云服务提供端云协同、端云共享和端云策略。
4
5端云协同提供结构化数据(RDB Store)端云同步的能力。即:云作为数据的中心节点,通过与云的数据同步,实现数据云备份、同账号设备间的数据一致性。
6
7端云共享是在端云协同能力基础上,实现跨账号的数据共享。其中,端云共享资源标识是指:对于应用发起共享的每一条数据记录,该条数据在进行端云同步时会生成唯一的共享资源标识(字符串类型的值),此标识则作为该条数据记录共享时的识别标识。
8
9端云共享参与者是指: 共享发起者根据好友列表选中的参与当前数据共享的所有人员。
10
11端云共享邀请码是指: 共享发起后,在共享的服务端会生成当前共享操作的邀请码,并将该邀请码附加到当前共享邀请中,通过push消息推送到被邀请者的设备端,被邀请者可以通过该邀请码进行邀请的确认。
12
13该模块提供以下端云服务相关的常用功能:
14
15- [Config](#config):提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
16- [sharing<sup>11+</sup>](#sharing11):提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
17
18> **说明:**
19>
20> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
21>
22> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.data.cloudData (端云服务)](js-apis-data-cloudData.md)。
23>
24> - 使用本模块需要实现云服务功能。
25
26## 导入模块
27
28```ts
29import { cloudData } from '@kit.ArkData';
30```
31
32## ClearAction
33
34清除本地下载的云端数据的行为枚举。
35
36**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
37
38| 名称      | 说明                         |
39| --------- | ---------------------------- |
40| CLEAR_CLOUD_INFO | 清除从云端下载的数据的云标识,相关数据作为本地数据保存。 |
41| CLEAR_CLOUD_DATA_AND_INFO |清除从云端下载的数据,不包括本地已修改的云端数据。   |
42
43## ExtraData<sup>11+</sup>
44
45透传数据,携带通知数据变更所需要的信息。
46
47**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
48
49| 名称      | 类型   | 必填 | 说明                                                         |
50| --------- | ------ | ---- | ------------------------------------------------------------ |
51| eventId   | string | 是   | 如果传值为"cloud_data_change",表示云数据变更。              |
52| extraData | string | 是   | 透传数据,extraData是json结构的字符串,其中必须包括"data"字段,"data"中是通知变更所需要的信息,包含账号、应用名、数据库名、数据库类型和数据库表名,所有字段均不能为空。
53
54**样例:**
55
56```ts
57//accountId:用户打开的云账号ID
58//bundleName:应用包名
59//containerName:云上数据库名称
60//databaseScopes:云上数据库类型
61//recordTypes:云上数据库表名
62
63interface ExtraData {
64  eventId: "cloud_data_change",
65  extraData: '{
66    "data": "{
67     "accountId": "aaa",
68     "bundleName": "com.bbb.xxx",
69     "containerName": "alias",
70     "databaseScopes": ["private", "shared"],
71     "recordTypes": ["xxx", "yyy", "zzz"]
72    }"
73  }'
74}
75
76```
77
78## StatisticInfo<sup>12+</sup>
79
80返回数据,携带端云同步统计信息所需要的信息。
81
82**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
83
84| 名称      | 类型   | 必填 | 说明                                                  |
85| --------- | ------ | ---- |-----------------------------------------------------|
86| table   | string | 是   | 查询的表名。如返回值为"cloud_notes",表示查询结果是表名为"cloud_notes"的同步信息。 |
87| inserted   | number | 是   | 本地新增且云端还未同步数据的条数,如返回值为2,表示本地新增2条数据且云端还未同步。          |
88| updated   | number | 是   | 云端同步之后本地或云端修改还未同步的条数,如返回值为2,表示本地或云端修改还有2条数据未同步。     |
89| normal | number | 是   | 端云一致的数据。如返回值为2,表示本地与云端一致的数据为2条。                     |
90
91## SyncInfo<sup>12+</sup>
92
93返回数据,上一次端云同步所需要的信息。
94
95**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
96
97| 名称       | 类型                                                         | 必填 | 说明                       |
98| ---------- | ------------------------------------------------------------ | ---- | -------------------------- |
99| startTime  | Date                                                         | 是   | 上一次端云同步的开始时间。 |
100| finishTime | Date                                                         | 是   | 上一次端云同步的结束时间。 |
101| code       | [relationalStore.ProgressCode](js-apis-data-relationalStore.md#progresscode10) | 是   | 上一次端云同步过程的状态。 |
102
103## Config
104
105提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
106
107### enableCloud
108
109static enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback&lt;void&gt;): void
110
111打开端云协同,使用callback异步回调。
112
113**需要权限**:ohos.permission.CLOUDDATA_CONFIG
114
115**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
116
117**参数:**
118
119| 参数名    | 类型                            | 必填 | 说明                                                         |
120| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
121| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
122| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
123| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                                                   |
124
125**错误码:**
126
127以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
128
129| 错误码ID | 错误信息                                             |
130| -------- | ---------------------------------------------------- |
131| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
132| 202      | Permission verification failed, application which is not a system application uses system API.|
133| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
134| 801      | Capability not supported.|
135
136**示例:**
137
138```ts
139import { BusinessError } from '@kit.BasicServicesKit';
140
141let account: string = 'test_id';
142let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
143try {
144  cloudData.Config.enableCloud(account, switches, (err: BusinessError) => {
145    if (err === undefined) {
146      console.info('Succeeded in enabling cloud');
147    } else {
148      console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
149    }
150  });
151} catch (e) {
152  let error = e as BusinessError;
153  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
154}
155```
156
157### enableCloud
158
159static enableCloud(accountId: string, switches: Record<string, boolean>): Promise&lt;void&gt;
160
161打开端云协同,使用Promise异步回调。
162
163**需要权限**:ohos.permission.CLOUDDATA_CONFIG
164
165**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
166
167**参数:**
168
169| 参数名    | 类型                            | 必填 | 说明                                                         |
170| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
171| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
172| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
173
174**返回值:**
175
176| 类型                | 说明                      |
177| ------------------- | ------------------------- |
178| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
179
180**错误码:**
181
182以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
183
184| 错误码ID | 错误信息                                             |
185| -------- | ---------------------------------------------------- |
186| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
187| 202      | Permission verification failed, application which is not a system application uses system API.|
188| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
189| 801      | Capability not supported.|
190
191**示例:**
192
193```ts
194import { BusinessError } from '@kit.BasicServicesKit';
195
196let account: string = 'test_id';
197let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
198try {
199  cloudData.Config.enableCloud(account, switches).then(() => {
200    console.info('Succeeded in enabling cloud');
201  }).catch((err: BusinessError) => {
202    console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
203  });
204} catch (e) {
205  let error = e as BusinessError;
206  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
207}
208```
209
210### disableCloud
211
212static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;): void
213
214关闭端云协同,使用callback异步回调。
215
216**需要权限**:ohos.permission.CLOUDDATA_CONFIG
217
218**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
219
220**参数:**
221
222| 参数名    | 类型                      | 必填 | 说明                 |
223| --------- | ------------------------- | ---- | -------------------- |
224| accountId | string                    | 是   | 具体打开的云账号ID。 |
225| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
226
227**错误码:**
228
229以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
230
231| 错误码ID | 错误信息                                             |
232| -------- | ---------------------------------------------------- |
233| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
234| 202      | Permission verification failed, application which is not a system application uses system API.|
235| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
236| 801      | Capability not supported.|
237
238**示例:**
239
240```ts
241import { BusinessError } from '@kit.BasicServicesKit';
242
243let account: string = 'test_id';
244try {
245  cloudData.Config.disableCloud(account, (err: BusinessError) => {
246    if (err === undefined) {
247      console.info('Succeeded in disabling cloud');
248    } else {
249      console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
250    }
251  });
252} catch (e) {
253  let error = e as BusinessError;
254  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
255}
256```
257
258### disableCloud
259
260static disableCloud(accountId: string): Promise&lt;void&gt;
261
262关闭端云协同,使用Promise异步回调。
263
264**需要权限**:ohos.permission.CLOUDDATA_CONFIG
265
266**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
267
268**参数:**
269
270| 参数名    | 类型   | 必填 | 说明                 |
271| --------- | ------ | ---- | -------------------- |
272| accountId | string | 是   | 具体打开的云账号ID。 |
273
274**返回值:**
275
276| 类型                | 说明                      |
277| ------------------- | ------------------------- |
278| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
279
280**错误码:**
281
282以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
283
284| 错误码ID | 错误信息                                             |
285| -------- | ---------------------------------------------------- |
286| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
287| 202      | Permission verification failed, application which is not a system application uses system API.|
288| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
289| 801      | Capability not supported.|
290
291**示例:**
292
293```ts
294import { BusinessError } from '@kit.BasicServicesKit';
295
296let account: string = 'test_id';
297try {
298  cloudData.Config.disableCloud(account).then(() => {
299    console.info('Succeeded in disabling cloud');
300  }).catch((err: BusinessError) => {
301    console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
302  });
303} catch (e) {
304  let error = e as BusinessError;
305  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
306}
307```
308
309### changeAppCloudSwitch
310
311static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback&lt;void&gt;): void
312
313修改单个应用端云协同开关,使用callback异步回调。
314
315**需要权限**:ohos.permission.CLOUDDATA_CONFIG
316
317**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
318
319**参数:**
320
321| 参数名    | 类型                            | 必填 | 说明                         |
322| --------- | ------------------------------- | ---- | ---------------------------- |
323| accountId | string                          | 是   | 具体打开的云账号ID。 |
324| bundleName| string                         | 是   | 应用名。 |
325| status    | boolean                        | 是   | 应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
326| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                   |
327
328**错误码:**
329
330以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
331
332| 错误码ID | 错误信息                                             |
333| -------- | ---------------------------------------------------- |
334| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
335| 202      | Permission verification failed, application which is not a system application uses system API.|
336| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
337| 801      | Capability not supported.|
338
339**示例:**
340
341```ts
342import { BusinessError } from '@kit.BasicServicesKit';
343
344let account: string = 'test_id';
345let bundleName: string = 'test_bundleName';
346try {
347  cloudData.Config.changeAppCloudSwitch(account, bundleName, true, (err: BusinessError) => {
348    if (err === undefined) {
349      console.info('Succeeded in changing App cloud switch');
350    } else {
351      console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
352    }
353  });
354} catch (e) {
355  let error = e as BusinessError;
356  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
357}
358```
359
360### changeAppCloudSwitch
361
362static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise&lt;void&gt;
363
364修改单个应用端云协同开关,使用Promise异步回调。
365
366**需要权限**:ohos.permission.CLOUDDATA_CONFIG
367
368**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
369
370**参数:**
371
372| 参数名    | 类型                            | 必填 | 说明                         |
373| --------- | ------------------------------- | ---- | ---------------------------- |
374| accountId | string                          | 是   | 具体打开的云账号ID。 |
375| bundleName| string                         | 是   | 应用名。 |
376| status    | boolean                        | 是   | 应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
377
378**返回值:**
379
380| 类型                | 说明                      |
381| ------------------- | ------------------------- |
382| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
383
384**错误码:**
385
386以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
387
388| 错误码ID | 错误信息                                             |
389| -------- | ---------------------------------------------------- |
390| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
391| 202      | Permission verification failed, application which is not a system application uses system API.|
392| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
393| 801      | Capability not supported.|
394
395**示例:**
396
397```ts
398import { BusinessError } from '@kit.BasicServicesKit';
399
400let account: string = 'test_id';
401let bundleName: string = 'test_bundleName';
402try {
403  cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
404    console.info('Succeeded in changing App cloud switch');
405  }).catch((err: BusinessError) => {
406    console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
407  });
408} catch (e) {
409  let error = e as BusinessError;
410  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
411}
412```
413
414### notifyDataChange
415
416static notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
417
418通知云端的数据变更,使用callback异步回调。
419
420**需要权限**:ohos.permission.CLOUDDATA_CONFIG
421
422**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
423
424**参数:**
425
426| 参数名     | 类型                      | 必填 | 说明                 |
427| ---------- | ------------------------- | ---- | -------------------- |
428| accountId  | string                    | 是   | 具体打开的云账号ID。 |
429| bundleName | string                    | 是   | 应用名。             |
430| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
431
432**错误码:**
433
434以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
435
436| 错误码ID | 错误信息                                             |
437| -------- | ---------------------------------------------------- |
438| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
439| 202      | Permission verification failed, application which is not a system application uses system API.|
440| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
441| 801      | Capability not supported.|
442
443**示例:**
444
445```ts
446import { BusinessError } from '@kit.BasicServicesKit';
447
448let account: string = 'test_id';
449let bundleName: string = 'test_bundleName';
450try {
451  cloudData.Config.notifyDataChange(account, bundleName, (err: BusinessError) => {
452    if (err === undefined) {
453      console.info('Succeeded in notifying the change of data');
454    } else {
455      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
456    }
457  });
458} catch (e) {
459  let error = e as BusinessError;
460  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
461}
462```
463
464### notifyDataChange
465
466static notifyDataChange(accountId: string,bundleName: string): Promise&lt;void&gt;
467
468通知云端的数据变更,使用Promise异步回调。
469
470**需要权限**:ohos.permission.CLOUDDATA_CONFIG
471
472**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
473
474**参数:**
475
476| 参数名     | 类型   | 必填 | 说明                 |
477| ---------- | ------ | ---- | -------------------- |
478| accountId  | string | 是   | 具体打开的云账号ID。 |
479| bundleName | string | 是   | 应用名。             |
480
481**返回值:**
482
483| 类型                | 说明                      |
484| ------------------- | ------------------------- |
485| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
486
487**错误码:**
488
489以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
490
491| 错误码ID | 错误信息                                             |
492| -------- | ---------------------------------------------------- |
493| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
494| 202      | Permission verification failed, application which is not a system application uses system API.|
495| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
496| 801      | Capability not supported.|
497
498**示例:**
499
500```ts
501import { BusinessError } from '@kit.BasicServicesKit';
502
503let account: string = 'test_id';
504let bundleName: string = 'test_bundleName';
505try {
506  cloudData.Config.notifyDataChange(account, bundleName).then(() => {
507    console.info('Succeeded in notifying the change of data');
508  }).catch((err: BusinessError) => {
509    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
510  });
511} catch (e) {
512  let error = e as BusinessError;
513  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
514}
515```
516
517### notifyDataChange<sup>11+</sup>
518
519 **static** notifyDataChange(extInfo: ExtraData, callback: AsyncCallback&lt;void&gt;):void
520
521通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,使用callback异步回调。
522
523**需要权限**:ohos.permission.CLOUDDATA_CONFIG
524
525**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
526
527**参数:**
528
529| 参数名   | 类型                      | 必填 | 说明                                    |
530| -------- | ------------------------- | ---- | --------------------------------------- |
531| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。 |
532| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
533
534**错误码:**
535
536以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
537
538| 错误码ID | 错误信息                                             |
539| -------- | ---------------------------------------------------- |
540| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
541| 202      | Permission verification failed, application which is not a system application uses system API.|
542| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
543| 801      | Capability not supported.|
544
545**示例:**
546
547```ts
548import { BusinessError } from '@kit.BasicServicesKit';
549
550let eventId: string = "cloud_data_change";
551let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
552try {
553  cloudData.Config.notifyDataChange({
554    eventId: eventId, extraData: extraData
555  }, (err: BusinessError) => {
556    if (err === undefined) {
557      console.info('Succeeded in notifying the change of data');
558    } else {
559      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
560    }
561  });
562} catch (e) {
563  let error = e as BusinessError;
564  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
565}
566```
567
568### notifyDataChange<sup>11+</sup>
569
570static notifyDataChange(extInfo: ExtraData, userId: number,callback: AsyncCallback&lt;void&gt;):void
571
572通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用callback异步回调。
573
574**需要权限**:ohos.permission.CLOUDDATA_CONFIG
575
576**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
577
578**参数:**
579
580| 参数名   | 类型                      | 必填 | 说明                                            |
581| -------- | ------------------------- | ---- | ----------------------------------------------- |
582| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。        |
583| userId   | number                    | 是   | 用户ID。对应为系统中现有的用户ID。 |
584| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
585
586**错误码:**
587
588以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
589
590| 错误码ID | 错误信息                                             |
591| -------- | ---------------------------------------------------- |
592| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
593| 202      | Permission verification failed, application which is not a system application uses system API.|
594| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
595| 801      | Capability not supported.|
596
597**示例:**
598
599```ts
600import { BusinessError } from '@kit.BasicServicesKit';
601
602let eventId: string = "cloud_data_change";
603let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
604let userId: number = 100;
605try {
606  cloudData.Config.notifyDataChange({
607    eventId: eventId, extraData: extraData
608  }, userId, (err: BusinessError) => {
609    if (err === undefined) {
610      console.info('Succeeded in notifying the change of data');
611    } else {
612      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
613    }
614  });
615} catch (e) {
616  let error = e as BusinessError;
617  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
618}
619```
620
621### notifyDataChange<sup>11+</sup>
622
623**static** notifyDataChange(extInfo: ExtraData, userId?: number): Promise&lt;void&gt;
624
625通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用Promise异步回调。
626
627**需要权限**:ohos.permission.CLOUDDATA_CONFIG
628
629**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
630
631**参数:**
632
633| 参数名  | 类型                    | 必填 | 说明                                            |
634| ------- | ----------------------- | ---- | ----------------------------------------------- |
635| extInfo | [ExtraData](#extradata11) | 是   | 透传数据 包含通知数据变更后的应用信息。         |
636| userId  | number                  | 否   | 表示用户ID。此参数是可选的,默认值是当前用户ID,如果指定了此参数,则该值必须是系统中现有的用户ID。 |
637
638**返回值:**
639
640| 类型                | 说明                      |
641| ------------------- | ------------------------- |
642| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
643
644**错误码:**
645
646以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
647
648| 错误码ID | 错误信息                                             |
649| -------- | ---------------------------------------------------- |
650| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
651| 202      | Permission verification failed, application which is not a system application uses system API.|
652| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
653| 801      | Capability not supported.|
654
655**示例:**
656
657```ts
658import { BusinessError } from '@kit.BasicServicesKit';
659
660let eventId: string = "cloud_data_change";
661let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
662let userId: number = 100;
663try {
664  cloudData.Config.notifyDataChange({
665    eventId: eventId, extraData: extraData
666  }, userId).then(() => {
667    console.info('Succeeded in notifying the change of data');
668  }).catch((err: BusinessError) => {
669    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
670  });
671} catch (e) {
672  let error = e as BusinessError;
673  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
674}
675```
676
677### queryStatistics<sup>12+</sup>
678
679static queryStatistics(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record&lt;string, Array&lt;StatisticInfo&gt;&gt;&gt;
680
681查询端云统计信息,返回未同步、已同步且端云信息一致和已同步且端云信息不一致的统计信息,使用Promise异步回调。
682
683**需要权限**:ohos.permission.CLOUDDATA_CONFIG
684
685**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
686
687**参数:**
688
689| 参数名  | 类型      | 必填 | 说明                                |
690| ------- |---------| ---- |-----------------------------------|
691| accountId | string  | 是   | 具体打开的云账号ID。                       |
692| bundleName | string  | 是   | 应用包名。                             |
693| storeId  | string  | 否   | 数据库名称。默认值为空字符串,此时将查询当前应用所有的本地数据库。 |
694
695**返回值:**
696
697| 类型                                                                                   | 说明                     |
698|--------------------------------------------------------------------------------------| ------------------------ |
699| Promise&lt;Record&lt;string, Array&lt;[StatisticInfo](#statisticinfo12)&gt;&gt;&gt; | 返回表名以及统计信息结果集。 |
700
701**错误码:**
702
703以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
704
705| 错误码ID | 错误信息                                             |
706| -------- | ---------------------------------------------------- |
707| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
708| 202      | Permission verification failed, application which is not a system application uses system API.|
709| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
710| 801      | Capability not supported.|
711
712**示例:**
713
714```ts
715import { BusinessError } from '@kit.BasicServicesKit';
716
717const accountId:string = "accountId";
718const bundleName:string = "bundleName";
719const storeId:string = "storeId";
720
721cloudData.Config.queryStatistics(accountId, bundleName, storeId).then((result) => {
722    console.info(`Succeeded in querying statistics. Info is ${JSON.stringify(result)}`);
723}).catch((err: BusinessError) => {
724    console.error(`Failed to query statistics. Error code is ${err.code}, message is ${err.message}`);
725});
726```
727
728### queryLastSyncInfo<sup>12+</sup>
729
730static queryLastSyncInfo(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record<string, SyncInfo>>
731
732查询上一次端云同步信息,使用Promise异步回调。
733
734**需要权限**:ohos.permission.CLOUDDATA_CONFIG
735
736**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
737
738**参数:**
739
740| 参数名     | 类型   | 必填 | 说明                                                         |
741| ---------- | ------ | ---- | ------------------------------------------------------------ |
742| accountId  | string | 是   | 具体打开的云账号ID。                                         |
743| bundleName | string | 是   | 应用包名。                                                   |
744| storeId    | string | 否   | 数据库名称。默认值为空字符串,此时查询当前应用下所有数据库上一次端云同步信息。 |
745
746**返回值:**
747
748| 类型                                                         | 说明                                         |
749| ------------------------------------------------------------ | -------------------------------------------- |
750| Promise&lt;Record&lt;string, [SyncInfo](#syncinfo12)&gt;&gt; | 返回数据库名以及上一次端云同步的信息结果集。 |
751
752**错误码:**
753
754以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
755
756| 错误码ID | 错误信息                                             |
757| -------- | ---------------------------------------------------- |
758| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
759| 202      | Permission verification failed, application which is not a system application uses system API.|
760| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
761| 801      | Capability not supported.|
762
763**示例:**
764
765```ts
766import { BusinessError } from '@kit.BasicServicesKit';
767
768const accountId:string = "accountId";
769const bundleName:string = "bundleName";
770const storeId:string = "storeId";
771try {
772    cloudData.Config.queryLastSyncInfo(accountId, bundleName, storeId).then((result) => {
773    	console.info(`Succeeded in querying last syncinfo. Info is ${JSON.stringify(result)}`);
774	}).catch((err: BusinessError) => {
775    	console.error(`Failed to query last syncinfo. Error code is ${err.code}, message is ${err.message}`);
776	});
777} catch(e) {
778    let error = e as BusinessError;
779  	console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
780}
781```
782
783### setGlobalCloudStrategy<sup>12+</sup>
784
785static setGlobalCloudStrategy(strategy: StrategyType, param?: Array&lt;commonType.ValueType&gt;): Promise&lt;void&gt;
786
787设置全局云同步策略,使用Promise异步回调。
788
789**需要权限**:ohos.permission.CLOUDDATA_CONFIG
790
791**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
792
793**参数:**
794
795| 参数名     | 类型                                                                     | 必填 | 说明                |
796| ---------- |------------------------------------------------------------------------| ---- |-------------------|
797| strategy  | [StrategyType](js-apis-data-cloudData.md#strategytype)    | 是   | 配置的策略类型。          |
798| param | Array&lt;[commonType.ValueType](js-apis-data-commonType.md#valuetype)&gt; | 否   | 策略参数。不填写默认为空,默认取消所有配置。 |
799
800**返回值:**
801
802| 类型                | 说明                      |
803| ------------------- | ------------------------- |
804| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
805
806**错误码:**
807
808以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
809
810| 错误码ID | 错误信息                                             |
811| -------- | ---------------------------------------------------- |
812| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
813| 202      | Permission verification failed, application which is not a system application uses system API.|
814| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
815| 801      | Capability not supported.|
816
817**示例:**
818
819```ts
820import { BusinessError } from '@kit.BasicServicesKit';
821
822cloudData.Config.setGlobalCloudStrategy(cloudData.StrategyType.NETWORK, [cloudData.NetWorkStrategy.WIFI]).then(() => {
823    console.info('Succeeded in setting the global cloud strategy');
824}).catch((err: BusinessError) => {
825    console.error(`Failed to set global cloud strategy. Code: ${err.code}, message: ${err.message}`);
826});
827```
828
829###  clear
830
831static clear(accountId: string, appActions: Record<string, ClearAction>,  callback: AsyncCallback&lt;void&gt;): void
832
833清除本地下载的云端数据,使用callback异步回调。
834
835**需要权限**:ohos.permission.CLOUDDATA_CONFIG
836
837**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
838
839**参数:**
840
841| 参数名     | 类型                                                | 必填 | 说明                             |
842| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
843| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
844| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
845| callback   | AsyncCallback&lt;void&gt;                           | 是   | 回调函数。                       |
846
847**错误码:**
848
849以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
850
851| 错误码ID | 错误信息                                             |
852| -------- | ---------------------------------------------------- |
853| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
854| 202      | Permission verification failed, application which is not a system application uses system API.|
855| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
856| 801      | Capability not supported.|
857
858**示例:**
859
860```ts
861import { BusinessError } from '@kit.BasicServicesKit';
862
863let account: string = "test_id";
864type dataType = Record<string, cloudData.ClearAction>
865let appActions: dataType = {
866  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
867  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
868};
869try {
870  cloudData.Config.clear(account, appActions, (err: BusinessError) => {
871    if (err === undefined) {
872      console.info('Succeeding in clearing cloud data');
873    } else {
874      console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
875    }
876  });
877} catch (e) {
878  let error = e as BusinessError;
879  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
880}
881```
882
883### clear
884
885static clear(accountId: string, appActions: Record<string, ClearAction>): Promise&lt;void&gt;
886
887清除本地下载的云端数据,使用Promise异步回调。
888
889**需要权限**:ohos.permission.CLOUDDATA_CONFIG
890
891**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
892
893**参数:**
894
895| 参数名     | 类型                                                | 必填 | 说明                             |
896| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
897| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
898| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
899
900**返回值:**
901
902| 类型                | 说明                      |
903| ------------------- | ------------------------- |
904| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
905
906**错误码:**
907
908以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
909
910| 错误码ID | 错误信息                                             |
911| -------- | ---------------------------------------------------- |
912| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
913| 202      | Permission verification failed, application which is not a system application uses system API.|
914| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
915| 801      | Capability not supported.|
916
917**示例:**
918
919```ts
920import { BusinessError } from '@kit.BasicServicesKit';
921
922let account: string = "test_id";
923type dataType = Record<string, cloudData.ClearAction>;
924let appActions: dataType = {
925  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
926  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
927};
928try {
929  cloudData.Config.clear(account, appActions).then(() => {
930    console.info('Succeeding in clearing cloud data');
931  }).catch((err: BusinessError) => {
932    console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
933  });
934} catch (e) {
935  let error = e as BusinessError;
936  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
937}
938```
939
940## sharing<sup>11+</sup>
941
942提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
943
944### Role<sup>11+</sup>
945
946端云共享参与者的角色。
947
948**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
949
950| 名称           | 值   | 说明                               |
951| --------------| ---- | ---------------------------------- |
952| ROLE_INVITER  | 0    | 端云共享邀请者。请使用枚举名称而非枚举值。 |
953| ROLE_INVITEE  | 1    | 端云共享被邀请者。请使用枚举名称而非枚举值。 |
954
955### State<sup>11+</sup>
956
957端云共享状态。
958
959**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
960
961| 名称           | 值   | 说明                               |
962| --------------| ---- | ---------------------------------- |
963| STATE_UNKNOWN    | 0    | 未知状态。请使用枚举名称而非枚举值。   |
964| STATE_ACCEPTED   | 1    | 端云共享已接受。请使用枚举名称而非枚举值。 |
965| STATE_REJECTED   | 2    | 端云共享被拒绝。请使用枚举名称而非枚举值。 |
966| STATE_SUSPENDED  | 3    | 端云共享被暂时挂起,未作处理。请使用枚举名称而非枚举值。 |
967| STATE_UNAVAILABLE<sup>12+</sup>   | 4    | 端云共享不可用。请使用枚举名称而非枚举值。 |
968
969### SharingCode<sup>11+</sup>
970
971端云共享错误码。
972
973**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
974
975| 名称           | 值   | 说明                               |
976| --------------| ---- | ---------------------------------- |
977| SUCCESS                 | 0    | 成功。请使用枚举名称而非枚举值。   |
978| REPEATED_REQUEST        | 1    | 重复邀请,表示当前参与者已被邀请。请使用枚举名称而非枚举值。 |
979| NOT_INVITER             | 2    | 非端云共享的邀请者,表示当前参与者不是端云共享的邀请者。请使用枚举名称而非枚举值。 |
980| NOT_INVITER_OR_INVITEE  | 3    | 非法参与者,表示当前参与者既不是共享的邀请者,也不是共享的被邀请者。请使用枚举名称而非枚举值。 |
981| OVER_QUOTA              | 4    | 端云共享次数达到上限,表示当前账号可共享的次数达到上限。请使用枚举名称而非枚举值。   |
982| TOO_MANY_PARTICIPANTS   | 5    | 端云共享参与者数量达到上限。请使用枚举名称而非枚举值。 |
983| INVALID_ARGS            | 6    | 无效的参数。请使用枚举名称而非枚举值。 |
984| NETWORK_ERROR           | 7    | 网络错误。请使用枚举名称而非枚举值。 |
985| CLOUD_DISABLED          | 8    | 云开关未打开。请使用枚举名称而非枚举值。   |
986| SERVER_ERROR            | 9    | 服务端发生错误。请使用枚举名称而非枚举值。 |
987| INNER_ERROR             | 10   | 系统发生内部错误。请使用枚举名称而非枚举值。 |
988| INVALID_INVITATION      | 11   | 无效的邀请,表示当前邀请已失效或不存在。请使用枚举名称而非枚举值。 |
989| RATE_LIMIT              | 12   | 速率限制,表示单次同步的数据量达到上限。请使用枚举名称而非枚举值。   |
990| CUSTOM_ERROR            | 1000 | 定制错误,小于该枚举值的错误码用于定义系统内部的标准错误码,大于该枚举值的错误码用于使用者自定义错误码。请使用枚举名称而非枚举值。 |
991
992### Result&lt;T&gt;<sup>11+</sup>
993
994端云共享结果的返回值。
995
996**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
997
998| 名称          | 类型                          | 必填  | 说明           |
999| ----------- | --------------------------- | --- | ------------ |
1000| code        | number                      | 是   | 错误码。       |
1001| description | string                      | 否   | 错误码详细描述,默认为undefined。       |
1002| value       | T                           | 否   | 返回结果的值,具体类型由参数T指定,默认为undefined。 |
1003
1004### Privilege<sup>11+</sup>
1005
1006指定的端云共享数据的权限。
1007
1008**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1009
1010| 名称          | 类型                          | 必填  | 说明           |
1011| ----------- | --------------------------- | --- | ------------ |
1012| writable    | boolean              | 否   | 被共享者是否可修改共享的数据。true表示可修改,false表示不可修改,默认不可修改。   |
1013| readable    | boolean              | 否   | 被共享者是否可读取共享的数据。true表示可读取,false表示不可读取,默认不可读取。   |
1014| creatable   | boolean              | 否   | 被共享者是否可创建新的共享数据。true表示可创建,false表示不可创建,默认不可创建。  |
1015| deletable   | boolean              | 否   | 被共享者是否可删除共享的数据。true表示可删除,false表示不可删除,默认不可删除。  |
1016| shareable   | boolean              | 否   | 被共享者是否可将共享的数据再次共享给其他参与者。true表示可再次共享,false表示不可再次共享,默认不可再次共享。  |
1017
1018### Participant<sup>11+</sup>
1019
1020端云共享的参与者。
1021
1022**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1023
1024| 名称          | 类型                          | 必填  | 说明           |
1025| ----------- | --------------------------- | --- | ------------ |
1026| identity    | string                  | 是   | 参与者的ID。              |
1027| role        | [Role](#role11)           | 否   | 参与者的角色,为邀请者或被邀请者。默认为undefined。  |
1028| state       | [State](#state11)         | 否   | 共享的状态。默认为undefined。 |
1029| privilege   | [Privilege](#privilege11) | 否   | 指定的共享数据权限。默认为[Privilege](#privilege11)的默认值。 |
1030| attachInfo  | string                  | 否   | 附加信息,用于拓展额外的参与者信息。如用于参与者身份校验的校验码等,默认为空字符串。 |
1031
1032### allocResourceAndShare<sup>11+</sup>
1033
1034allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns?: Array&lt;string&gt;): Promise&lt;relationalStore.ResultSet&gt;
1035
1036根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。如果指定了列字段,则返回的结果集中同时包含对应列的字段值,使用Promise异步回调。
1037
1038**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1039
1040**参数:**
1041
1042| 参数名    | 类型                            | 必填 | 说明                         |
1043| --------- | ------------------------------- | ---- | ---------------------------- |
1044| storeId      | string                        | 是   | 数据库名称。 |
1045| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1046| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1047| columns      | Array&lt;string&gt;           | 否   | 表示要查找的列字段名。默认为undefined,不返回列字段。 |
1048
1049**返回值:**
1050
1051| 类型                | 说明                      |
1052| ------------------- | ------------------------- |
1053| Promise&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt; | Promise对象,返回查询并共享的共享资源标识结果集。 |
1054
1055**错误码:**
1056
1057以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1058
1059| 错误码ID | 错误信息                                             |
1060| -------- | ---------------------------------------------------- |
1061| 202      | Permission verification failed, application which is not a system application uses system API.|
1062| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1063| 801      | Capability not supported.|
1064
1065**示例:**
1066
1067```ts
1068import { BusinessError } from '@kit.BasicServicesKit';
1069import { relationalStore } from '@kit.ArkData';
1070
1071let participants = new Array<cloudData.sharing.Participant>();
1072participants.push({
1073  identity: '000000000',
1074  role: cloudData.sharing.Role.ROLE_INVITER,
1075  state: cloudData.sharing.State.STATE_UNKNOWN,
1076  privilege: {
1077    writable: true,
1078    readable: true,
1079    creatable: false,
1080    deletable: false,
1081    shareable: false
1082  },
1083  attachInfo: ''
1084})
1085let sharingResource: string;
1086let predicates = new relationalStore.RdbPredicates('test_table');
1087predicates.equalTo('data', 'data_test');
1088cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data']).then((resultSet) => {
1089  if (!resultSet.goToFirstRow()) {
1090    console.error(`row error`);
1091    return;
1092  }
1093  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1094  console.info(`sharing resource: ${res}`);
1095  sharingResource = res;
1096}).catch((err: BusinessError) => {
1097  console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1098})
1099
1100```
1101
1102### allocResourceAndShare<sup>11+</sup>
1103
1104allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1105
1106根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。并根据指定的列字段,返回的结果集中同时包含对应列的字段值,使用callback异步回调。
1107
1108**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1109
1110**参数:**
1111
1112| 参数名    | 类型                            | 必填 | 说明                         |
1113| --------- | ------------------------------- | ---- | ---------------------------- |
1114| storeId      | string                        | 是   | 数据库名称。 |
1115| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1116| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1117| columns      | Array&lt;string&gt;           | 是   | 表示要查找的列字段名。 |
1118| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | 是  | 回调函数。 返回查询并共享的共享资源标识结果集。 |
1119
1120**错误码:**
1121
1122以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1123
1124| 错误码ID | 错误信息                                             |
1125| -------- | ---------------------------------------------------- |
1126| 202      | Permission verification failed, application which is not a system application uses system API.|
1127| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1128| 801      | Capability not supported.|
1129
1130**示例:**
1131
1132```ts
1133import { relationalStore } from '@kit.ArkData';
1134import { BusinessError } from '@kit.BasicServicesKit';
1135
1136let participants = new Array<cloudData.sharing.Participant>();
1137participants.push({
1138  identity: '000000000',
1139  role: cloudData.sharing.Role.ROLE_INVITER,
1140  state: cloudData.sharing.State.STATE_UNKNOWN,
1141  privilege: {
1142    writable: true,
1143    readable: true,
1144    creatable: false,
1145    deletable: false,
1146    shareable: false
1147  },
1148  attachInfo: ''
1149})
1150let sharingResource: string;
1151let predicates = new relationalStore.RdbPredicates('test_table');
1152predicates.equalTo('data', 'data_test');
1153cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data'], (err: BusinessError, resultSet) => {
1154  if (err) {
1155    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1156    return;
1157  }
1158  if (!resultSet.goToFirstRow()) {
1159    console.error(`row error`);
1160    return;
1161  }
1162  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1163  console.info(`sharing resource: ${res}`);
1164  sharingResource = res;
1165})
1166
1167```
1168
1169### allocResourceAndShare<sup>11+</sup>
1170
1171allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1172
1173根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集,使用callback异步回调。
1174
1175**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1176
1177**参数:**
1178
1179| 参数名    | 类型                            | 必填 | 说明                         |
1180| --------- | ------------------------------- | ---- | ---------------------------- |
1181| storeId      | string                        | 是   | 数据库名称。 |
1182| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1183| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1184| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | 是   | 回调函数。返回查询并共享的共享资源标识结果集。 |
1185
1186**错误码:**
1187
1188以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1189
1190| 错误码ID | 错误信息                                             |
1191| -------- | ---------------------------------------------------- |
1192| 202      | Permission verification failed, application which is not a system application uses system API.|
1193| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1194| 801      | Capability not supported.|
1195
1196**示例:**
1197
1198```ts
1199import { relationalStore } from '@kit.ArkData';
1200import { BusinessError } from '@kit.BasicServicesKit';
1201
1202let participants = new Array<cloudData.sharing.Participant>();
1203participants.push({
1204  identity: '000000000',
1205  role: cloudData.sharing.Role.ROLE_INVITER,
1206  state: cloudData.sharing.State.STATE_UNKNOWN,
1207  privilege: {
1208    writable: true,
1209    readable: true,
1210    creatable: false,
1211    deletable: false,
1212    shareable: false
1213  },
1214  attachInfo: ''
1215})
1216let sharingResource: string;
1217let predicates = new relationalStore.RdbPredicates('test_table');
1218predicates.equalTo('data', 'data_test');
1219cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, (err: BusinessError, resultSet) => {
1220  if (err) {
1221    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1222    return;
1223  }
1224  if (!resultSet.goToFirstRow()) {
1225    console.error(`row error`);
1226    return;
1227  }
1228  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1229  console.info(`sharing resource: ${res}`);
1230  sharingResource = res;
1231})
1232
1233```
1234
1235### share<sup>11+</sup>
1236
1237share(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1238
1239根据指定的共享资源标识和共享参与者发起共享邀请,使用Promise异步回调。
1240
1241**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1242
1243**参数:**
1244
1245| 参数名    | 类型                            | 必填 | 说明                         |
1246| --------- | ------------------------------- | ---- | ---------------------------- |
1247| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1248| participants      | Array&lt;[Participant](#participant11)&gt;   | 是   | 端云共享的参与者。 |
1249
1250**返回值:**
1251
1252| 类型                | 说明                      |
1253| ------------------- | ------------------------- |
1254| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回端云共享的结果。 |
1255
1256**错误码:**
1257
1258以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1259
1260| 错误码ID | 错误信息                                             |
1261| -------- | ---------------------------------------------------- |
1262| 202      | Permission verification failed, application which is not a system application uses system API.|
1263| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1264| 801      | Capability not supported.|
1265
1266**示例:**
1267
1268```ts
1269import { BusinessError } from '@kit.BasicServicesKit';
1270
1271let participants = new Array<cloudData.sharing.Participant>();
1272participants.push({
1273  identity: '000000000',
1274  role: cloudData.sharing.Role.ROLE_INVITER,
1275  state: cloudData.sharing.State.STATE_UNKNOWN,
1276  privilege: {
1277    writable: true,
1278    readable: true,
1279    creatable: false,
1280    deletable: false,
1281    shareable: false
1282  },
1283  attachInfo: ''
1284})
1285cloudData.sharing.share('sharing_resource_test', participants).then((result) => {
1286  console.info(`share success, result: ${result}`);
1287}).catch((err: BusinessError) => {
1288  console.error(`share failed, code is ${err.code},message is ${err.message}`);
1289})
1290
1291```
1292
1293### share<sup>11+</sup>
1294
1295share(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1296
1297根据指定的共享资源标识和共享参与者发起共享邀请,使用callback异步回调。
1298
1299**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1300
1301**参数:**
1302
1303| 参数名    | 类型                            | 必填 | 说明                         |
1304| --------- | ------------------------------- | ---- | ---------------------------- |
1305| sharingResource  | string                                     | 是   | 端云共享数据的资源标识。 |
1306| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1307| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回端云共享的结果。 |
1308
1309**错误码:**
1310
1311以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1312
1313| 错误码ID | 错误信息                                             |
1314| -------- | ---------------------------------------------------- |
1315| 202      | Permission verification failed, application which is not a system application uses system API.|
1316| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1317| 801      | Capability not supported.|
1318
1319**示例:**
1320
1321```ts
1322import { BusinessError } from '@kit.BasicServicesKit';
1323
1324let participants = new Array<cloudData.sharing.Participant>();
1325participants.push({
1326  identity: '000000000',
1327  role: cloudData.sharing.Role.ROLE_INVITER,
1328  state: cloudData.sharing.State.STATE_UNKNOWN,
1329  privilege: {
1330    writable: true,
1331    readable: true,
1332    creatable: false,
1333    deletable: false,
1334    shareable: false
1335  },
1336  attachInfo: ''
1337})
1338cloudData.sharing.share('sharing_resource_test', participants, ((err: BusinessError, result) => {
1339  if (err) {
1340    console.error(`share failed, code is ${err.code},message is ${err.message}`);
1341    return;
1342  }
1343  console.info(`share succeeded, result: ${result}`);
1344}))
1345
1346```
1347
1348### unshare<sup>11+</sup>
1349
1350unshare(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1351
1352根据指定的共享资源标识和共享参与者取消共享,使用Promise异步回调。
1353
1354**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1355
1356**参数:**
1357
1358| 参数名    | 类型                            | 必填 | 说明                         |
1359| --------- | ------------------------------- | ---- | ---------------------------- |
1360| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1361| participants      | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1362
1363**返回值:**
1364
1365| 类型                | 说明                      |
1366| ------------------- | ------------------------- |
1367| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回取消共享的结果。 |
1368
1369**错误码:**
1370
1371以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1372
1373| 错误码ID | 错误信息                                             |
1374| -------- | ---------------------------------------------------- |
1375| 202      | Permission verification failed, application which is not a system application uses system API.|
1376| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1377| 801      | Capability not supported.|
1378
1379**示例:**
1380
1381```ts
1382import { BusinessError } from '@kit.BasicServicesKit';
1383
1384let participants = new Array<cloudData.sharing.Participant>();
1385participants.push({
1386  identity: '000000000',
1387  role: cloudData.sharing.Role.ROLE_INVITER,
1388  state: cloudData.sharing.State.STATE_UNKNOWN,
1389  privilege: {
1390    writable: true,
1391    readable: true,
1392    creatable: false,
1393    deletable: false,
1394    shareable: false
1395  },
1396  attachInfo: ''
1397})
1398cloudData.sharing.unshare('sharing_resource_test', participants).then((result) => {
1399  console.info(`unshare succeeded, result: ${result}`);
1400}).catch((err: BusinessError) => {
1401  console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1402})
1403
1404```
1405
1406### unshare<sup>11+</sup>
1407
1408unshare(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1409
1410根据指定的共享资源标识和共享参与者取消共享,使用callback异步回调。
1411
1412**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1413
1414**参数:**
1415
1416| 参数名    | 类型                            | 必填 | 说明                         |
1417| --------- | ------------------------------- | ---- | ---------------------------- |
1418| sharingResource  | string                                     | 是   | 共享数据的资源标志。 |
1419| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 共享参与者。 |
1420| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回取消共享的结果。 |
1421
1422**错误码:**
1423
1424以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1425
1426| 错误码ID | 错误信息                                             |
1427| -------- | ---------------------------------------------------- |
1428| 202      | Permission verification failed, application which is not a system application uses system API.|
1429| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1430| 801      | Capability not supported.|
1431
1432**示例:**
1433
1434```ts
1435import { BusinessError } from '@kit.BasicServicesKit';
1436
1437let participants = new Array<cloudData.sharing.Participant>();
1438participants.push({
1439  identity: '000000000',
1440  role: cloudData.sharing.Role.ROLE_INVITER,
1441  state: cloudData.sharing.State.STATE_UNKNOWN,
1442  privilege: {
1443    writable: true,
1444    readable: true,
1445    creatable: false,
1446    deletable: false,
1447    shareable: false
1448  },
1449  attachInfo: ''
1450})
1451cloudData.sharing.unshare('sharing_resource_test', participants, ((err: BusinessError, result) => {
1452  if (err) {
1453    console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1454    return;
1455  }
1456  console.info(`unshare succeeded, result: ${result}`);
1457}))
1458
1459```
1460
1461### exit<sup>11+</sup>
1462
1463exit(sharingResource: string): Promise&lt;Result&lt;void&gt;&gt;
1464
1465根据指定的共享资源标识退出共享,使用Promise异步回调。
1466
1467**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1468
1469**参数:**
1470
1471| 参数名    | 类型                            | 必填 | 说明                         |
1472| --------- | ------------------------------- | ---- | ---------------------------- |
1473| sharingResource   | string       | 是   | 端云共享数据的资源标识。 |
1474
1475**返回值:**
1476
1477| 类型                | 说明                      |
1478| ------------------- | ------------------------- |
1479| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; | Promise对象,返回退出端云共享的结果。 |
1480
1481**错误码:**
1482
1483以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1484
1485| 错误码ID | 错误信息                                             |
1486| -------- | ---------------------------------------------------- |
1487| 202      | Permission verification failed, application which is not a system application uses system API.|
1488| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1489| 801      | Capability not supported.|
1490
1491**示例:**
1492
1493```ts
1494import { BusinessError } from '@kit.BasicServicesKit';
1495
1496cloudData.sharing.exit('sharing_resource_test').then((result) => {
1497  console.info(`exit share success, result: ${result}`);
1498}).catch((err: BusinessError) => {
1499  console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1500})
1501
1502```
1503
1504### exit<sup>11+</sup>
1505
1506exit(sharingResource: string, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void
1507
1508根据指定的共享资源标识退出共享,使用callback异步回调。
1509
1510**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1511
1512**参数:**
1513
1514| 参数名    | 类型                            | 必填 | 说明                         |
1515| --------- | ------------------------------- | ---- | ---------------------------- |
1516| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1517| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt;  | 是   | 回调函数。返回退出共享的结果。 |
1518
1519**错误码:**
1520
1521以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1522
1523| 错误码ID | 错误信息                                             |
1524| -------- | ---------------------------------------------------- |
1525| 202      | Permission verification failed, application which is not a system application uses system API.|
1526| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1527| 801      | Capability not supported.|
1528
1529**示例:**
1530
1531```ts
1532import { BusinessError } from '@kit.BasicServicesKit';
1533
1534cloudData.sharing.exit('sharing_resource_test', ((err: BusinessError, result) => {
1535  if (err) {
1536    console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1537    return;
1538  }
1539  console.info(`exit share succeeded, result: ${result}`);
1540}))
1541
1542```
1543
1544### changePrivilege<sup>11+</sup>
1545
1546changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1547
1548根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用Promise异步回调。
1549
1550**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1551
1552**参数:**
1553
1554| 参数名    | 类型                            | 必填 | 说明                         |
1555| --------- | ------------------------------- | ---- | ---------------------------- |
1556| sharingResource   | string                                    | 是   | 端云共享数据的资源标识。 |
1557| participants      | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1558
1559**返回值:**
1560
1561| 类型                | 说明                      |
1562| ------------------- | ------------------------- |
1563| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回更改共享参与者权限的结果。 |
1564
1565**错误码:**
1566
1567以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1568
1569| 错误码ID | 错误信息                                             |
1570| -------- | ---------------------------------------------------- |
1571| 202      | Permission verification failed, application which is not a system application uses system API.|
1572| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1573| 801      | Capability not supported.|
1574
1575**示例:**
1576
1577```ts
1578import { BusinessError } from '@kit.BasicServicesKit';
1579
1580let participants = new Array<cloudData.sharing.Participant>();
1581participants.push({
1582  identity: '000000000',
1583  role: cloudData.sharing.Role.ROLE_INVITER,
1584  state: cloudData.sharing.State.STATE_UNKNOWN,
1585  privilege: {
1586    writable: true,
1587    readable: true,
1588    creatable: false,
1589    deletable: false,
1590    shareable: false
1591  },
1592  attachInfo: ''
1593})
1594
1595cloudData.sharing.changePrivilege('sharing_resource_test', participants).then((result) => {
1596  console.info(`change privilege succeeded, result: ${result}`);
1597}).catch((err: BusinessError) => {
1598  console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1599})
1600
1601```
1602
1603### changePrivilege<sup>11+</sup>
1604
1605changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1606
1607根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用callback异步回调。
1608
1609**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1610
1611**参数:**
1612
1613| 参数名    | 类型                            | 必填 | 说明                         |
1614| --------- | ------------------------------- | ---- | ---------------------------- |
1615| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1616| participants     | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1617| callback         | callback: AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回更改权限的结果。 |
1618
1619**错误码:**
1620
1621以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1622
1623| 错误码ID | 错误信息                                             |
1624| -------- | ---------------------------------------------------- |
1625| 202      | Permission verification failed, application which is not a system application uses system API.|
1626| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1627| 801      | Capability not supported.|
1628
1629**示例:**
1630
1631```ts
1632import { BusinessError } from '@kit.BasicServicesKit';
1633
1634let participants = new Array<cloudData.sharing.Participant>();
1635participants.push({
1636  identity: '000000000',
1637  role: cloudData.sharing.Role.ROLE_INVITER,
1638  state: cloudData.sharing.State.STATE_UNKNOWN,
1639  privilege: {
1640    writable: true,
1641    readable: true,
1642    creatable: false,
1643    deletable: false,
1644    shareable: false
1645  },
1646  attachInfo: ''
1647})
1648
1649cloudData.sharing.changePrivilege('sharing_resource_test', participants, ((err: BusinessError, result) => {
1650  if (err) {
1651    console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1652    return;
1653  }
1654  console.info(`change privilege succeeded, result: ${result}`);
1655}))
1656
1657```
1658
1659### queryParticipants<sup>11+</sup>
1660
1661queryParticipants(sharingResource: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1662
1663根据指定的共享资源标识查询当前共享的参与者,使用Promise异步回调。
1664
1665**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1666
1667**参数:**
1668
1669| 参数名    | 类型                            | 必填 | 说明                         |
1670| --------- | ------------------------------- | ---- | ---------------------------- |
1671| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1672
1673**返回值:**
1674
1675| 类型                | 说明                      |
1676| ------------------- | ------------------------- |
1677| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查询共享参与者的结果。 |
1678
1679**错误码:**
1680
1681以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1682
1683| 错误码ID | 错误信息                                             |
1684| -------- | ---------------------------------------------------- |
1685| 202      | Permission verification failed, application which is not a system application uses system API.|
1686| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1687| 801      | Capability not supported.|
1688
1689**示例:**
1690
1691```ts
1692import { BusinessError } from '@kit.BasicServicesKit';
1693
1694cloudData.sharing.queryParticipants('sharing_resource_test').then((result) => {
1695  console.info(`query participants succeeded, result: ${result}`);
1696}).catch((err: BusinessError) => {
1697  console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1698})
1699
1700```
1701
1702### queryParticipants<sup>11+</sup>
1703
1704queryParticipants(sharingResource: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1705
1706根据指定的共享资源标识查询当前共享的参与者,使用callback异步回调。
1707
1708**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1709
1710**参数:**
1711
1712| 参数名    | 类型                            | 必填 | 说明                         |
1713| --------- | ------------------------------- | ---- | ---------------------------- |
1714| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1715| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt;  | 是   | 回调函数。返回查找共享参与者的结果。 |
1716
1717**错误码:**
1718
1719以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1720
1721| 错误码ID | 错误信息                                             |
1722| -------- | ---------------------------------------------------- |
1723| 202      | Permission verification failed, application which is not a system application uses system API.|
1724| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1725| 801      | Capability not supported.|
1726
1727**示例:**
1728
1729```ts
1730import { BusinessError } from '@kit.BasicServicesKit';
1731
1732cloudData.sharing.queryParticipants('sharing_resource_test', ((err: BusinessError, result) => {
1733  if (err) {
1734    console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1735    return;
1736  }
1737  console.info(`query participants succeeded, result: ${result}`);
1738}))
1739
1740```
1741
1742### queryParticipantsByInvitation<sup>11+</sup>
1743
1744queryParticipantsByInvitation(invitationCode: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1745
1746根据指定的共享邀请码查询当前共享的参与者,使用Promise异步回调。
1747
1748**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1749
1750**参数:**
1751
1752| 参数名    | 类型                            | 必填 | 说明                         |
1753| --------- | ------------------------------- | ---- | ---------------------------- |
1754| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1755
1756**返回值:**
1757
1758| 类型                | 说明                      |
1759| ------------------- | ------------------------- |
1760| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查找共享参与者的结果。|
1761
1762**错误码:**
1763
1764以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1765
1766| 错误码ID | 错误信息                                             |
1767| -------- | ---------------------------------------------------- |
1768| 202      | Permission verification failed, application which is not a system application uses system API.|
1769| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1770| 801      | Capability not supported.|
1771
1772**示例:**
1773
1774```ts
1775import { BusinessError } from '@kit.BasicServicesKit';
1776
1777cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test').then((result) => {
1778  console.info(`query participants by invitation succeeded, result: ${result}`);
1779}).catch((err: BusinessError) => {
1780  console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1781})
1782
1783```
1784
1785### queryParticipantsByInvitation<sup>11+</sup>
1786
1787queryParticipantsByInvitation(invitationCode: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1788
1789根据指定的共享邀请码查询当前共享的参与者,使用callback异步回调。
1790
1791**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1792
1793**参数:**
1794
1795| 参数名    | 类型                            | 必填 | 说明                         |
1796| --------- | ------------------------------- | ---- | ---------------------------- |
1797| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1798| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | 是   | 回调函数。返回查找共享参与者的结果。 |
1799
1800**错误码:**
1801
1802以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1803
1804| 错误码ID | 错误信息                                             |
1805| -------- | ---------------------------------------------------- |
1806| 202      | Permission verification failed, application which is not a system application uses system API.|
1807| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1808| 801      | Capability not supported.|
1809
1810**示例:**
1811
1812```ts
1813import { BusinessError } from '@kit.BasicServicesKit';
1814
1815cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test', ((err: BusinessError, result) => {
1816  if (err) {
1817    console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1818    return;
1819  }
1820  console.info(`query participants by invitation succeeded, result: ${result}`);
1821}))
1822
1823```
1824
1825### confirmInvitation<sup>11+</sup>
1826
1827confirmInvitation(invitationCode: string, state: State): Promise&lt;Result&lt;string&gt;&gt;
1828
1829被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用Promise异步回调。
1830
1831**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1832
1833**参数:**
1834
1835| 参数名    | 类型                            | 必填 | 说明                         |
1836| --------- | ------------------------------- | ---- | ---------------------------- |
1837| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1838| state            | [State](#state11)        | 是   | 确认邀请的状态。 |
1839
1840**返回值:**
1841
1842| 类型                | 说明                      |
1843| ------------------- | ------------------------- |
1844| Promise&lt;[Result](#resultt11)&lt;string&gt;&gt; | Promise对象,返回确认共享邀请的结果。 |
1845
1846**错误码:**
1847
1848以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1849
1850| 错误码ID | 错误信息                                             |
1851| -------- | ---------------------------------------------------- |
1852| 202      | Permission verification failed, application which is not a system application uses system API.|
1853| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1854| 801      | Capability not supported.|
1855
1856**示例:**
1857
1858```ts
1859import { BusinessError } from '@kit.BasicServicesKit';
1860
1861let shareResource: string | undefined;
1862cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED).then((result: cloudData.sharing.Result<string>) => {
1863  console.info(`confirm invitation succeeded, result: ${result}`);
1864  shareResource = result.value;
1865}).catch((err: BusinessError) => {
1866  console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1867})
1868
1869```
1870
1871### confirmInvitation<sup>11+</sup>
1872
1873confirmInvitation(invitationCode: string, state: State, callback: AsyncCallback&lt;Result&lt;string&gt;&gt;): void
1874
1875被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用callback异步回调。
1876
1877**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1878
1879**参数:**
1880
1881| 参数名    | 类型                            | 必填 | 说明                         |
1882| --------- | ------------------------------- | ---- | ---------------------------- |
1883| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1884| state           | [State](#state11)       | 是   | 确认邀请的状态。 |
1885| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;string&gt;&gt; | 是   | 回调函数。返回确认邀请的结果。 |
1886
1887**错误码:**
1888
1889以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1890
1891| 错误码ID | 错误信息                                             |
1892| -------- | ---------------------------------------------------- |
1893| 202      | Permission verification failed, application which is not a system application uses system API.|
1894| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1895| 801      | Capability not supported.|
1896
1897**示例:**
1898
1899```ts
1900import { BusinessError } from '@kit.BasicServicesKit';
1901
1902let shareResource: string;
1903cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED, ((err: BusinessError, result) => {
1904  if (err) {
1905    console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1906    return;
1907  }
1908  console.info(`confirm invitation succeeded, result: ${result}`);
1909  shareResource = result.value;
1910}))
1911
1912```
1913
1914### changeConfirmation<sup>11+</sup>
1915
1916changeConfirmation(sharingResource: string, state: State): Promise&lt;Result&lt;void&gt;&gt;
1917
1918根据共享资源标识更改共享邀请的状态,使用Promise异步回调。
1919
1920**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1921
1922**参数:**
1923
1924| 参数名    | 类型                            | 必填 | 说明                         |
1925| --------- | ------------------------------- | ---- | ---------------------------- |
1926| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1927| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
1928
1929**返回值:**
1930
1931| 类型                | 说明                      |
1932| ------------------- | ------------------------- |
1933| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; |  Promise对象,返回更改共享邀请状态的结果。 |
1934
1935**错误码:**
1936
1937以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1938
1939| 错误码ID | 错误信息                                             |
1940| -------- | ---------------------------------------------------- |
1941| 202      | Permission verification failed, application which is not a system application uses system API.|
1942| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1943| 801      | Capability not supported.|
1944
1945**示例:**
1946
1947```ts
1948import { BusinessError } from '@kit.BasicServicesKit';
1949
1950cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED).then((result) => {
1951  console.info(`change confirmation succeeded, result: ${result}`);
1952}).catch((err: BusinessError) => {
1953  console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
1954})
1955
1956```
1957
1958### changeConfirmation<sup>11+</sup>
1959
1960changeConfirmation(sharingResource: string, state: State, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void;
1961
1962根据共享资源标识更改共享邀请的状态,使用callback异步回调。
1963
1964**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1965
1966**参数:**
1967
1968| 参数名    | 类型                            | 必填 | 说明                         |
1969| --------- | ------------------------------- | ---- | ---------------------------- |
1970| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1971| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
1972| callback          | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt; | 是   | 回调函数。返回更改邀请状态的结果。 |
1973
1974**错误码:**
1975
1976以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1977
1978| 错误码ID | 错误信息                                             |
1979| -------- | ---------------------------------------------------- |
1980| 202      | Permission verification failed, application which is not a system application uses system API.|
1981| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1982| 801      | Capability not supported.|
1983
1984**示例:**
1985
1986```ts
1987import { BusinessError } from '@kit.BasicServicesKit';
1988
1989cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED, ((err: BusinessError, result) => {
1990  if (err) {
1991    console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
1992    return;
1993  }
1994  console.info(`change confirmation succeeded, result: ${result}`);
1995}))
1996
1997```
1998<!--no_check-->
1999