@wix/wix-data-items-sdk 1.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +8 -0
  2. package/build/cjs/context.d.ts +1 -0
  3. package/build/cjs/context.js +18 -0
  4. package/build/cjs/context.js.map +1 -0
  5. package/build/cjs/index.d.ts +1 -0
  6. package/build/cjs/index.js +18 -0
  7. package/build/cjs/index.js.map +1 -0
  8. package/build/cjs/index.typings.d.ts +1 -0
  9. package/build/cjs/index.typings.js +18 -0
  10. package/build/cjs/index.typings.js.map +1 -0
  11. package/build/cjs/meta.d.ts +1 -0
  12. package/build/cjs/meta.js +18 -0
  13. package/build/cjs/meta.js.map +1 -0
  14. package/build/cjs/src/data-items-api-client.d.ts +64 -0
  15. package/build/cjs/src/data-items-api-client.js +305 -0
  16. package/build/cjs/src/data-items-api-client.js.map +1 -0
  17. package/build/cjs/src/data-v2-data-item-items.context.d.ts +18 -0
  18. package/build/cjs/src/data-v2-data-item-items.context.js +51 -0
  19. package/build/cjs/src/data-v2-data-item-items.context.js.map +1 -0
  20. package/build/cjs/src/data-v2-data-item-items.meta.d.ts +27 -0
  21. package/build/cjs/src/data-v2-data-item-items.meta.js +103 -0
  22. package/build/cjs/src/data-v2-data-item-items.meta.js.map +1 -0
  23. package/build/cjs/src/data-v2-data-item-items.public.d.ts +32 -0
  24. package/build/cjs/src/data-v2-data-item-items.public.js +126 -0
  25. package/build/cjs/src/data-v2-data-item-items.public.js.map +1 -0
  26. package/build/cjs/src/data-v2-data-item-items.universal.d.ts +651 -0
  27. package/build/cjs/src/data-v2-data-item-items.universal.js +741 -0
  28. package/build/cjs/src/data-v2-data-item-items.universal.js.map +1 -0
  29. package/build/cjs/src/wix-data-api.d.ts +4 -0
  30. package/build/cjs/src/wix-data-api.js +13 -0
  31. package/build/cjs/src/wix-data-api.js.map +1 -0
  32. package/build/es/context.d.ts +1 -0
  33. package/build/es/context.js +2 -0
  34. package/build/es/context.js.map +1 -0
  35. package/build/es/index.d.ts +1 -0
  36. package/build/es/index.js +2 -0
  37. package/build/es/index.js.map +1 -0
  38. package/build/es/index.typings.d.ts +1 -0
  39. package/build/es/index.typings.js +2 -0
  40. package/build/es/index.typings.js.map +1 -0
  41. package/build/es/meta.d.ts +1 -0
  42. package/build/es/meta.js +2 -0
  43. package/build/es/meta.js.map +1 -0
  44. package/build/es/src/data-items-api-client.d.ts +64 -0
  45. package/build/es/src/data-items-api-client.js +300 -0
  46. package/build/es/src/data-items-api-client.js.map +1 -0
  47. package/build/es/src/data-v2-data-item-items.context.d.ts +18 -0
  48. package/build/es/src/data-v2-data-item-items.context.js +32 -0
  49. package/build/es/src/data-v2-data-item-items.context.js.map +1 -0
  50. package/build/es/src/data-v2-data-item-items.meta.d.ts +27 -0
  51. package/build/es/src/data-v2-data-item-items.meta.js +62 -0
  52. package/build/es/src/data-v2-data-item-items.meta.js.map +1 -0
  53. package/build/es/src/data-v2-data-item-items.public.d.ts +32 -0
  54. package/build/es/src/data-v2-data-item-items.public.js +103 -0
  55. package/build/es/src/data-v2-data-item-items.public.js.map +1 -0
  56. package/build/es/src/data-v2-data-item-items.universal.d.ts +651 -0
  57. package/build/es/src/data-v2-data-item-items.universal.js +717 -0
  58. package/build/es/src/data-v2-data-item-items.universal.js.map +1 -0
  59. package/build/es/src/wix-data-api.d.ts +4 -0
  60. package/build/es/src/wix-data-api.js +10 -0
  61. package/build/es/src/wix-data-api.js.map +1 -0
  62. package/context/package.json +6 -0
  63. package/meta/package.json +6 -0
  64. package/package.json +77 -0
@@ -0,0 +1,651 @@
1
+ import { WixDataUpdateOptions, WixDataReadOptions, WixDataOptions, WixDataAggregate, WixDataBulkPatch, WixDataBulkResult, WixDataBulkError, WixDataItem, WixDataReadWithProjectionOptions, WixDataQuery, WixDataPatch, WixDataResult, QueryBase, WixDataFilter } from '@wix/wix-data-items-common';
2
+ /**
3
+ * Adds an item to a collection.
4
+ *
5
+ * An item can only be inserted into an existing collection. You can create a new collection using the
6
+ * Data Collections API.
7
+ *
8
+ * The `insert()` function returns a Promise that resolves to the inserted item
9
+ * after it has been added to the specified collection. The Promise is rejected
10
+ * if the current user does not have "create" permissions for the collection or
11
+ * the specified item includes an `_id` property whose value matches an
12
+ * existing ID in the collection. Meaning, `insert()` cannot overwrite an
13
+ * existing item in the collection.
14
+ *
15
+ * Calling the `insert()` function triggers the `beforeInsert()` and
16
+ * `afterInsert()` hooks if they have been defined.
17
+ *
18
+ * Use the `options` parameter to run `insert()` from backend code without
19
+ * checking for permissions or without its registered hooks.
20
+ *
21
+ * When inserting an item into a collection that has a reference field, set the
22
+ * value of the reference field to the referenced item's `_id` value or the entire referenced item object.
23
+ *
24
+ * The `insert()` function adds the following properties and values to the item
25
+ * when it adds it to the collection:
26
+ * - `_id`: A unique identifier for an item in a collection, if the item
27
+ * doesn't have one or has one that is `undefined`. You can optionally provide
28
+ * your own ID. Once an ID is assigned to an item it cannot be changed.
29
+ * - `_createdDate`: The date the item was added to the collection.
30
+ * - `_updatedDate`: The date the item was modified. When the item is first
31
+ * added, the `_createdDate` and `_updatedDate` are the same.
32
+ *
33
+ * Any valid JavaScript object can be added as a property value. The `insert()`
34
+ * function maintains the structure of the specified object. For example, objects that contain nested objects, Arrays, or Arrays with nested objects are all added to the collection as defined.
35
+ *
36
+ * The maximum size of an item that you can add to a collection is 500kb.
37
+ *
38
+ * > **Notes:**
39
+ * > - If an item's `_id` property value is set to `null` or an empty string,
40
+ * an error is thrown.
41
+ * > - When creating a Single Item Collection, an item with the system field
42
+ * > `_id` is pre-inserted into the collection. Single Item Collections may
43
+ * > contain only one item.
44
+ * > - If there is a pre-existing item in a Single Item Collection, the
45
+ * > `insert()` function will not run. To update or change an item in a
46
+ * > Single Item Collection see the `update()` and `save()` functions.
47
+ * > - The `insert()` function does not support multi-reference fields. For
48
+ * > multi-reference fields, use `insertReference()`.
49
+ * @public
50
+ * @param dataCollectionId - ID of the collection item belongs to.
51
+ * @param item - Data item to insert.
52
+ * @param options - An object containing options to use when processing this operation.
53
+ * @documentationMaturity preview
54
+ * @requiredField dataCollectionId
55
+ * @requiredField item
56
+ * @permissionScope Write Data Items
57
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
58
+ */
59
+ export declare function insert(dataCollectionId: string, item: Partial<WixDataItem>, options?: WixDataUpdateOptions): Promise<WixDataItem>;
60
+ /**
61
+ * Updates an item in a collection.
62
+ *
63
+ * The `update()` function returns a Promise that resolves to the updated item from
64
+ * the specified collection. The Promise is rejected if the current user does not
65
+ * have update permissions for the collection.
66
+ *
67
+ * Calling the `update()` function triggers the `beforeUpdate()` and `afterUpdate()`
68
+ * hooks if they have been defined.
69
+ *
70
+ * > **Note:**
71
+ * > The specified item must include an `_id` property that already exists in
72
+ * > the collection.
73
+ *
74
+ * The `update()` function compares the `_id` property of the specified item
75
+ * with the `_id` property values of the items in the specified collection. If
76
+ * an item in the collection has that `_id` value, `update()` replaces the
77
+ * item's property values with the ones in the specified item. If the existing
78
+ * item had properties with values and those properties were not included in
79
+ * the specified item, the values in those properties are lost. The item's
80
+ * `_updatedDate` property is also updated to the current date.
81
+ *
82
+ * Any valid JavaScript object can be used as a property value. The `update()`
83
+ * function maintains the structure of the specified object. For example,
84
+ * objects that contain nested objects, Arrays, or Arrays with nested objects
85
+ * are all added to the collection as defined.
86
+ *
87
+ * Use the `options` parameter to run `update()` from backend code without
88
+ * checking for permissions or without its registered hooks.
89
+ *
90
+ * When updating an item in a collection that has a reference field, set the
91
+ * value of the reference field to the referenced item's `_id` value or the
92
+ * entire referenced item object.
93
+ *
94
+ * The maximum size of an item that you can update in a collection is 500kb.
95
+ *
96
+ * > **Note:**
97
+ * > The update() function does not support multi-reference fields. For
98
+ * > multi-reference fields, use replaceReferences() or insertReference().
99
+ * @param dataCollectionId - ID of the collection item belongs to.
100
+ * @param item - Data item to update.
101
+ * @param options - An object containing options to use when processing this operation.
102
+ * @public
103
+ * @documentationMaturity preview
104
+ * @requiredField dataCollectionId
105
+ * @requiredField item
106
+ * @permissionScope Write Data Items
107
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
108
+ */
109
+ export declare function update(dataCollectionId: string, item: WixDataItem, options?: WixDataUpdateOptions): Promise<WixDataItem>;
110
+ /**
111
+ * Inserts or updates an item in a collection.
112
+ *
113
+ * The `save()` function returns a Promise that resolves to the inserted or
114
+ * updated item after it has been added or updated in the specified
115
+ * collection. The Promise is rejected if the current user does not have
116
+ * the necessary permissions for the collection.
117
+ *
118
+ * The `save()` function inserts or updates the specified item, depending on
119
+ * whether it already exists in the collection. It compares the `_id` property
120
+ * value of the specified item with the `_id` property values of the items in
121
+ * the specified collection. If an item in the collection has that `_id` value,
122
+ * `save()` uses `update()` to update the item in the collection, triggering
123
+ * the `beforeUpdate()` and `afterUpdate()` hooks if they have been defined.
124
+ * If none of the items in the collection contain that `_id` value, the
125
+ * specified item does not have an `_id` property, or if the specified item's
126
+ * id property is `undefined`, `save()` uses `insert()` to add the specified
127
+ * item to the collection. This triggers the `beforeInsert()` and
128
+ * `afterInsert()` hooks if they have been defined.
129
+ *
130
+ * Use the `options` parameter to run `save()` from backend code without
131
+ * checking for permissions or without its registered hooks.
132
+ *
133
+ * When saving an item to a collection that has a reference field, set the
134
+ * value of the reference field to the referenced item's `_id` value or the
135
+ * entire referenced item object.
136
+ *
137
+ * The maximum size of an item that you can save to a collection is 500kb.
138
+ *
139
+ * > **Notes:**
140
+ * > - If an item's `_id` property value is set to null or an empty string, an
141
+ * > error is thrown.
142
+ * > - The `save()` function does not support multi-reference fields. For
143
+ * > multi-reference fields, use `insertReference() `or `replaceReferences()`.
144
+ * @public
145
+ * @documentationMaturity preview
146
+ * @requiredField dataCollectionId
147
+ * @requiredField item
148
+ * @param dataCollectionId - ID of the collection item belongs to.
149
+ * @param item - Data item to save.
150
+ * @param options - An object containing options to use when processing this operation.
151
+ * @permissionScope Write Data Items
152
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
153
+ */
154
+ export declare function save(dataCollectionId: string, item: Partial<WixDataItem>, options?: WixDataUpdateOptions): Promise<WixDataItem>;
155
+ /**
156
+ * Retrieves an item from a collection.
157
+ *
158
+ * The `get()` function returns a Promise that resolves to the item with ID
159
+ * `itemId` from the specified collection, or `null` if the `itemId` is not
160
+ * found. The Promise is rejected if the current user does not have read
161
+ * permissions for the collection.
162
+ *
163
+ * If the specified collection contains reference fields, the ID of the
164
+ * referenced item is returned. To return the values of the referenced items
165
+ * use `query()` and `include()`.
166
+ *
167
+ * Calling the `get()` function triggers the `beforeGet()` and `afterGet()`
168
+ * hooks if they have been defined.
169
+ *
170
+ * Use the `options` parameter to run `get()` from backend code without
171
+ * checking for permissions or without its registered hooks.
172
+ *
173
+ * > **Notes:**
174
+ * > - When using the `query()` or `get()` functions or another data retrieval
175
+ * > method following a change to your database collection, the data
176
+ * > retrieved may not contain your most recent changes. See Wix-data and
177
+ * > Eventual Consistency for more information. To solve this problem, you
178
+ * > can use the `setTimeout()` function to delay retrieving data following
179
+ * > any changes to your database collection.
180
+ * > - An `itemId` is required to retrieve an item even from a single-item
181
+ * > collection.
182
+ * @param dataCollectionId - ID of the collection item belongs to.
183
+ * @param itemId - ID of the data item to retrieve.
184
+ * @param options - An object containing options to use when processing this operation.
185
+ * @public
186
+ * @documentationMaturity preview
187
+ * @requiredField itemId
188
+ * @requiredField dataCollectionId.
189
+ * @permissionScope Read Data Items
190
+ * @permissionScopeId SCOPE.DC-DATA.READ
191
+ * @returns Retrieved item.
192
+ */
193
+ export declare function get(dataCollectionId: string, itemId: string, options?: WixDataReadWithProjectionOptions): Promise<WixDataItem | null>;
194
+ /**
195
+ * Removes an item from a collection.
196
+ *
197
+ * The `remove()` function returns a Promise that resolves to the removed item
198
+ * after it has been removed from the specified collection. The Promise is
199
+ * rejected if the current user does not have "delete" permissions for the
200
+ * collection.
201
+ *
202
+ * Calling the `remove()` function triggers the `beforeRemove()` and
203
+ * `afterRemove()` hooks if they have been defined.
204
+ *
205
+ * Use the `options` parameter to run `remove()` from backend code without
206
+ * checking for permissions or without its registered hooks.
207
+ *
208
+ * > **Notes:**
209
+ * > The `remove()` function also clears multiple-item reference fields for
210
+ * > items in collections referenced by the specified item. For example,
211
+ * > suppose you have a **Movies** collection with an **Actors** field that
212
+ * > contains multiple references to items in a **People** collection. Removing
213
+ * > an item in the **Movies** collection also clears the data in the
214
+ * > corresponding multiple-item reference fields in the **People** collection.
215
+ * @param dataCollectionId - ID of the collection item belongs to.
216
+ * @param itemId - ID of the item to remove.
217
+ * @param options - An object containing options to use when processing this operation.
218
+ * @public
219
+ * @documentationMaturity preview
220
+ * @requiredField itemId
221
+ * @requiredField dataCollectionId
222
+ * @permissionScope Write Data Items
223
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
224
+ */
225
+ export declare function remove(dataCollectionId: string, itemId: string, options?: WixDataOptions): Promise<WixDataItem | null>;
226
+ /**
227
+ * Removes all items from a collection.
228
+ *
229
+ * The `truncate()` function returns a Promise that resolves after all items
230
+ * have been removed from the specified collection.
231
+ *
232
+ * `truncate()` runs when at least one of the following is true:
233
+ * - The current user is the site owner.
234
+ * - The request is performed in backend code with a `suppressAuth` options
235
+ * value of `true`.
236
+ *
237
+ * Calling the `truncate()` function does not trigger any hooks.
238
+ *
239
+ * > **Note:** `truncate()` also clears multiple-item reference fields in
240
+ * > collections referenced by the specified collection. For example, suppose you
241
+ * > have a **Movies** collection with an **Actors** field that contains multiple
242
+ * > references to items in a People collection. Truncating the **Movies**
243
+ * > collection also clears the data in the corresponding multiple-item reference
244
+ * > field in the People collection.
245
+ * @public
246
+ * @documentationMaturity preview
247
+ * @requiredField dataCollectionId
248
+ * @param dataCollectionId - ID of the collection to truncate.
249
+ * @permissionScope Write Data Items
250
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
251
+ */
252
+ export declare function truncate(dataCollectionId: string): Promise<void>;
253
+ /**
254
+ * Adds a number of items to a collection.
255
+ *
256
+ * The `bulkInsert()` function returns a Promise that resolves after the items
257
+ * have been added to the specified collection. The Promise is rejected if the
258
+ * current user does not have "create" permissions for the collection. Items
259
+ * are skipped if they include an `_id` property whose value matches an
260
+ * existing ID in the collection. Meaning, `bulkInsert()` cannot overwrite an
261
+ * existing item in the collection.
262
+ *
263
+ * Calling the `bulkInsert()` function triggers the `beforeInsert()` and
264
+ * `afterInsert()` hooks for each item that is inserted if the hooks have been
265
+ * defined.
266
+ *
267
+ * Use the options parameter to run `bulkInsert()` from backend code without
268
+ * checking for permissions or without its registered hooks.
269
+ *
270
+ * When inserting items into a collection that has a reference field, set the
271
+ * values of the reference fields to the referenced item's `_id` value or the
272
+ * entire referenced item object.
273
+ *
274
+ * The `bulkInsert()` function adds the following properties and values to the
275
+ * item when it adds it to the collection:
276
+ * - `_id`: A unique identifier for an item in a collection, if the item
277
+ * doesn't have one or has one that is `undefined`. You can optionally
278
+ * provide your own ID. Once an ID is assigned to an item it cannot be
279
+ * changed.
280
+ * - `_createdDate`: The date the item was added to the collection.
281
+ * - `_updatedDate`: The date the item was modified. When the item is first
282
+ * added, the `createdDate` and `updatedDate` are the same.
283
+ *
284
+ * Any valid JavaScript object can be added as a property value. The
285
+ * `bulkInsert()` function maintains the structure of the specified object. For
286
+ * example, objects that contain nested objects, Arrays, or Arrays with nested
287
+ * objects are all added to the collection as defined.
288
+ *
289
+ * The maximum size of an item that you can add to a collection is 500kb.
290
+ *
291
+ * > **Notes:**
292
+ * > - If an item's `_id` property value is set to `null` or an empty string,
293
+ * > an error is thrown.
294
+ * > - Bulk operations are limited to 1000 items per function call.
295
+ * > - The `bulkInsert()` function is not supported for Single Item Collections.
296
+ * > - The `bulkInsert()` function does not support multi-reference fields. For
297
+ * > multi-reference fields, use `insertReference()`.
298
+ * @public
299
+ * @documentationMaturity preview
300
+ * @requiredField dataCollectionId
301
+ * @requiredField items
302
+ * @param dataCollectionId - ID of the collection items belong to.
303
+ * @param items - Data items to insert.
304
+ * @param options - An object containing options to use when processing this operation.
305
+ * @permissionScope Write Data Items
306
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
307
+ */
308
+ export declare function bulkInsert(dataCollectionId: string, items: Partial<WixDataItem>[], options?: WixDataOptions): Promise<WixDataBulkResult>;
309
+ /**
310
+ * Updates a number of items in a collection.
311
+ *
312
+ * The `bulkUpdate()` function returns a Promise that resolves after the items
313
+ * have been updated in the specified collection. The Promise is rejected if
314
+ * the current user does not have update permissions for the collection. Items
315
+ * are skipped if they include an `_id` property whose value does not match an
316
+ * existing ID in the collection. Meaning, `bulkUpdate()` cannot add new items
317
+ * into the collection.
318
+ *
319
+ * Calling the `bulkUpdate()` function triggers the `beforeUpdate()` and
320
+ * `afterUpdate()` hooks for each item that is updated if the hooks have been
321
+ * defined.
322
+ *
323
+ * The `bulkUpdate()` function compares the `_id` property of the specified
324
+ * items with the `_id` property values of the items in the specified
325
+ * collection.
326
+ *
327
+ * > **Warning:** If an existing item in the specified collection matches the
328
+ * > `_id` of the specified item, bulkUpdate replaces the existing item's
329
+ * > property values with the ones in the specified item. **If the existing
330
+ * > item had properties with values and those properties were not included in
331
+ * > the specified item, the values in those properties are lost.** The item's
332
+ * `_updatedDate` property is also updated to the current date.
333
+ *
334
+ * Any valid JavaScript object can be used as a property value. The
335
+ * `bulkUpdate()` function maintains the structure of the specified object. For
336
+ * example, objects that contain nested objects, Arrays, or Arrays with nested
337
+ * objects are all added to the collection as defined.
338
+ *
339
+ * Use the options parameter to run `bulkUpdate()` from backend code without
340
+ * checking for permissions or without its registered hooks.
341
+ *
342
+ * When updating items in a collection that has a reference field, set the
343
+ * values of the reference field to the referenced item's `_id` value or the
344
+ * entire referenced item object.
345
+ *
346
+ * The maximum size of an item that you can update in a collection is 500kb.
347
+ *
348
+ * > **Notes:**
349
+ * > - Bulk operations are limited to 1000 items per function call.
350
+ * > - The `bulkUpdate()` function is not supported for Single Item Collections.
351
+ * > - The `bulkUpdate()` function does not support multi-reference fields. For
352
+ * > multi-reference fields, use `replaceReferences()` or `insertReference()`.
353
+ * @public
354
+ * @documentationMaturity preview
355
+ * @requiredField dataCollectionId
356
+ * @requiredField items
357
+ * @param dataCollectionId - ID of the collection items belong to.
358
+ * @param items - Data items to update.
359
+ * @param options - An object containing options to use when processing this operation.
360
+ * @permissionScope Write Data Items
361
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
362
+ */
363
+ export declare function bulkUpdate(dataCollectionId: string, items: WixDataItem[], options?: WixDataOptions): Promise<WixDataBulkResult>;
364
+ /**
365
+ * Inserts or updates a number of items in a collection.
366
+ *
367
+ * The `bulkSave()` function returns a Promise that resolves after the items
368
+ * have been added or updated in the specified collection. The Promise is
369
+ * rejected if the current user does not have the necessary permissions for the
370
+ * collection.
371
+ *
372
+ * The `bulkSave()` function inserts or updates the specified items, depending
373
+ * on whether they already exist in the collection. It compares the `_id`
374
+ * property value of the specified items with the `_id` property values of the
375
+ * items in the specified collection.
376
+ *
377
+ * - If an item in the collection has the specified `_id` value, `bulkSave()`
378
+ * uses `update()` to update the item in the collection, triggering the
379
+ * `beforeUpdate()` and `afterUpdate()` hooks for that item if they have been
380
+ * defined.
381
+ * - If none of the items in the collection contain that `_id` value, the
382
+ * specified item does not have an `_id` property, or if the specified item's
383
+ * `_id` property is `undefined`, `bulkSave()` uses `insert()` to add the
384
+ * specified item into the collection. This triggers the `beforeInsert()` and
385
+ * `afterInsert()` hooks for that item if they have been defined.
386
+ *
387
+ * Use the `options` parameter to run `bulkSave()` from backend code without
388
+ * checking for permissions or without its registered hooks.
389
+ *
390
+ * When saving items to a collection that has a reference field, set the values
391
+ * of the reference fields to the referenced item's `_id` value or the entire
392
+ * referenced item object.
393
+ *
394
+ * The maximum size of an item that you can save to a collection is 500kb.
395
+ *
396
+ * > **Notes:**
397
+ * > - If an item's `_id` property value is set to null or an empty string, an
398
+ * > error is thrown.
399
+ * > - Bulk operations are limited to 1000 items per function call.
400
+ * > - The `bulkSave()` function is not supported for Single Item Collections.
401
+ * > - The `bulkSave()` function does not support multi-reference fields. For
402
+ * > multi-reference fields, use `replaceReferences()` or
403
+ * > `insertReference()`.
404
+ * @public
405
+ * @documentationMaturity preview
406
+ * @requiredField dataCollectionId
407
+ * @requiredField items
408
+ * @param dataCollectionId - ID of the collection items belong to.
409
+ * @param items - Data items to save.
410
+ * @param options - An object containing options to use when processing this operation.
411
+ * @permissionScope Write Data Items
412
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
413
+ */
414
+ export declare function bulkSave(dataCollectionId: string, items: Partial<WixDataItem>[], options?: WixDataOptions): Promise<WixDataBulkResult>;
415
+ /**
416
+ * Removes a number of items from a collection.
417
+ *
418
+ * The `bulkRemove()` function returns a Promise that resolves after the items
419
+ * have been removed from the specified collection. The Promise is rejected if
420
+ * the current user does not have "delete" permissions for the collection. If
421
+ * the delete permissions for the collection are set to Site member author, the
422
+ * only items that will be deleted are those for which the current user is the
423
+ * owner. All other items will be skipped.
424
+ *
425
+ * Calling the `bulkRemove()` function triggers the `beforeRemove()` and
426
+ * `afterRemove()` hooks for each item that is deleted if the hooks have been
427
+ * defined.
428
+ *
429
+ * Use the options parameter to run `bulkRemove()` from backend code without
430
+ * checking for permissions or without its registered hooks.
431
+ *
432
+ * > **Notes:**
433
+ * > - The `bulkRemove()` function also clears multiple-item reference fields
434
+ * > for items in collections referenced by the specified items. For example,
435
+ * > suppose you have a **Movies** collection with an **Actors** field that
436
+ * > contains multiple references to items in a **People** collection.
437
+ * > Removing items in the **Movies** collection also clears the data in the
438
+ * > corresponding multiple-item reference fields in the People collection.
439
+ * > - Bulk operations are limited to 1000 items per function call.
440
+ * @public
441
+ * @documentationMaturity preview
442
+ * @requiredField dataCollectionId
443
+ * @requiredField dataItemIds
444
+ * @param dataCollectionId - ID of the collection items belong to.
445
+ * @param itemIds - IDs of the items to remove. The array must contain at least one item. Passing an empty array returns an error.
446
+ * @param options - An object containing options to use when processing this operation.
447
+ * @permissionScope Write Data Items
448
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
449
+ */
450
+ export declare function bulkRemove(dataCollectionId: string, itemIds: string[], options?: WixDataOptions): Promise<WixDataBulkResult>;
451
+ /**
452
+ * Checks if a reference to the referenced item exists in the specified
453
+ * property of the referring item.
454
+ *
455
+ * The `isReferenced()` function returns a Promise that resolves to true if the
456
+ * referring item contains a reference to the referenced item in the specified
457
+ * property. The Promise is rejected if the current user does not have read
458
+ * permissions for the collection.
459
+ *
460
+ * Calling the `isReferenced()` function does not trigger any hooks.
461
+ *
462
+ * > **Note:** The `isReferenced()` function is not supported for Single Item
463
+ * > Collections.
464
+ * @public
465
+ * @documentationMaturity preview
466
+ * @requiredField dataCollectionId
467
+ * @requiredField referencedItemId
468
+ * @requiredField referringItemFieldName
469
+ * @requiredField referringItemId
470
+ * @param dataCollectionId - ID of the collection containing the referring item.
471
+ * @param propertyName - Field to check for a reference to the item that may be referenced.
472
+ * @param referringItem - The referring item.
473
+ * @param referencedItem - Item that may be referenced.
474
+ * @param options - Options for checking whether a field contains a reference to an item.
475
+ * @permissionScope Read Data Items
476
+ * @permissionScopeId SCOPE.DC-DATA.READ
477
+ */
478
+ export declare function isReferenced(dataCollectionId: string, propertyName: string, referringItem: WixDataItem | string, referencedItem: WixDataItem | string, options?: WixDataReadOptions): Promise<boolean>;
479
+ /**
480
+ * Inserts a reference in the specified property.
481
+ *
482
+ * The `insertReference()` function returns a Promise that resolves when a
483
+ * reference to the referenced item(s) is added to the referring item in the
484
+ * specified property. The Promise is rejected if the current user does not
485
+ * have update permissions for the collection.
486
+ *
487
+ * Calling the `insertReference()` function does not trigger any hooks.
488
+ *
489
+ * > **Notes:**
490
+ * > - The `insertReference()` function only applies to multi-reference fields.
491
+ * > - The `insertReference()` function is not supported for Single Item
492
+ * > Collections.
493
+ * @public
494
+ * @documentationMaturity preview
495
+ * @requiredField dataCollectionId
496
+ * @requiredField propertyName
497
+ * @requiredField referringItem
498
+ * @requiredField referencedItem
499
+ * @param dataCollectionId - The ID of the collection that contains the referring item.
500
+ * @param propertyName - The property to insert the reference into.
501
+ * @param referringItem - The referring item or referring item's ID.
502
+ * @param referencedItem - The referenced item, referenced item's ID, an array of referenced items, or an array of referenced item IDs.
503
+ * @param options - An object containing options to use when processing this operation.
504
+ * @permissionScope Write Data Items
505
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
506
+ */
507
+ export declare function insertReference(dataCollectionId: string, propertyName: string, referringItem: WixDataItem | string, referencedItem: WixDataItem | string | WixDataItem[] | string[], options?: WixDataOptions): Promise<void>;
508
+ /**
509
+ * Removes a reference from the specified property.
510
+ *
511
+ * The `removeReference()` function returns a Promise that resolves when a
512
+ * reference to the referenced item(s) is removed from the specified property
513
+ * in the referring item. The Promise is rejected if the current user does not
514
+ * have update permissions for the collection.
515
+ *
516
+ * Calling the `removeReference()` function does not trigger any hooks.
517
+ *
518
+ * > **Note:** The `removeReference()` function is not supported for Single
519
+ * > Item Collections.
520
+ * @public
521
+ * @documentationMaturity preview
522
+ * @requiredField dataCollectionId
523
+ * @requiredField propertyName
524
+ * @requiredField referringItem
525
+ * @requiredField referencedItem
526
+ * @param dataCollectionId - The ID of the collection that contains the referring item.
527
+ * @param propertyName - The property to remove the reference from.
528
+ * @param referringItem - The referring item or referring item's ID.
529
+ * @param referencedItem - The referenced item, referenced item's ID, an array of referenced items, or an array of referenced item IDs.
530
+ * @param options - An object containing options to use when processing this operation.
531
+ * @permissionScope Write Data Items
532
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
533
+ */
534
+ export declare function removeReference(dataCollectionId: string, propertyName: string, referringItem: WixDataItem | string, referencedItem: WixDataItem | string | WixDataItem[] | string[], options?: WixDataOptions): Promise<void>;
535
+ /**
536
+ * Replaces current references with references in the specified property.
537
+ *
538
+ * The `replaceReferences()` function returns a Promise that resolves when the
539
+ * item's current references in the specified property are removed and
540
+ * references to the referenced items are added in their place. The Promise is
541
+ * rejected if the current user does not have update permissions for the
542
+ * collection.
543
+ *
544
+ * Calling the `replaceReferences()` function does not trigger any hooks.
545
+ *
546
+ * > **Note:** The `replaceReferences()` function is not supported for Single
547
+ * > Item Collections.
548
+ * @public
549
+ * @documentationMaturity preview
550
+ * @requiredField dataCollectionId
551
+ * @requiredField propertyName
552
+ * @requiredField referringItem
553
+ * @requiredField referencedItem
554
+ * @param dataCollectionId - The ID of the collection that contains the referring item.
555
+ * @param propertyName - The property to replaces the references in.
556
+ * @param referringItem - The referring item or referring item's ID.
557
+ * @param referencedItem - The referenced item, referenced item's ID, an array of referenced items, or an array of referenced item IDs.
558
+ * @param options - An object containing options to use when processing this operation.
559
+ * @permissionScope Write Data Items
560
+ * @permissionScopeId SCOPE.DC-DATA.WRITE
561
+ */
562
+ export declare function replaceReferences(dataCollectionId: string, propertyName: string, referringItem: WixDataItem | string, referencedItem: WixDataItem | string | WixDataItem[] | string[], options?: WixDataOptions): Promise<void>;
563
+ export declare function patch(dataCollectionId: string, itemId: string): WixDataPatch;
564
+ export declare function bulkPatch(dataCollectionId: string, itemIds: string[]): WixDataBulkPatch;
565
+ /**
566
+ * Creates a query to retrieve items from a database collection.
567
+ *
568
+ * The `query()` function builds a query to retrieve data items from a collection and returns a `WixDataQueryBuilder` object.
569
+ *
570
+ * The returned object contains the query definition which is typically used to run the query using the `find()` function.
571
+ *
572
+ * You can refine the query by chaining `WixDataQueryBuilder` functions onto the query. `WixDataQueryBuilder` functions enable you to sort, filter, and control the results that `query()` returns.
573
+ *
574
+ * The functions that are chained to `query()` are applied in the order they are called. For example, if you sort on an `age` field in ascending order and then on a `name` field in descending order, the results are sorted first by the age of the items and then, if there are multiple results with the same age, the items are sorted by name in descending order, per age value.
575
+ *
576
+ * If the collection that you are querying has references to other collections, by default the data from referenced collections is not retrieved. To get the data from referenced items, specify them using `include()` function.
577
+ *
578
+ * > **Note**: When calling `query()` following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
579
+ *
580
+ *
581
+ * @public
582
+ * @documentationMaturity preview
583
+ * @requiredField dataCollectionId
584
+ * @param dataCollectionId - The ID of the collection to run the query on.
585
+ * @permissionScope Read Data Items
586
+ * @permissionScopeId SCOPE.DC-DATA.READ
587
+ * @applicableIdentity APP
588
+ */
589
+ export declare function query(dataCollectionId: string): WixDataQuery;
590
+ /**
591
+ * Creates an aggregation on a data collection.
592
+ *
593
+ * The `aggregate()` function builds an aggregation on the specified collection and returns a `WixDataAggregate` object.
594
+ *
595
+ * An aggregation enables you to perform certain calculations on your collection data, or on groups of items that you define, to retrieve meaningful summaries.
596
+ * You can also add paging, filtering, and sorting preferences to your aggregation to retrieve exactly what you need.
597
+ *
598
+ * The returned object contains the aggregate definition which is typically used to run the aggregation using the `run()` function.
599
+ *
600
+ * You can refine the aggregation by chaining `WixDataAggregate` functions on to the aggregate.
601
+ * @public
602
+ * @documentationMaturity preview
603
+ * @requiredField dataCollectionId
604
+ * @param dataCollectionId - The ID of the collection to run the aggregation on.
605
+ * @permissionScope Read Data Items
606
+ * @permissionScopeId SCOPE.DC-DATA.READ
607
+ * @applicableIdentity APP
608
+ */
609
+ export declare function aggregate(dataCollectionId: string): WixDataAggregate;
610
+ /**
611
+ * Retrieves the full items referenced in the specified field of an item.
612
+ *
613
+ * Reference and multi-reference fields refer to items in different collections.
614
+ * Use this function to retrieve the full details of the referenced items themselves.
615
+ *
616
+ * For example, suppose you have a **Movies** collection with an **Actors** field that contains references to items in a **People** collection.
617
+ * Querying the **Movies** collection using `queryReferenced()` returns the relevant **People** items referenced in the **Actors** field of the specified **Movie** item.
618
+ * This gives you information from the **People** collection about each of the actors in the specified movie.
619
+ *
620
+ * > **Note**: When calling `queryReferenced()` following an update to your collection, the data retrieved may not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
621
+ * @public
622
+ * @documentationMaturity preview
623
+ * @requiredField dataCollectionId
624
+ * @requiredField holdingItem
625
+ * @requiredField relationshipAttribute
626
+ * @param dataCollectionId - The ID of the collection that contains the referring item.
627
+ * @param holdingItem - The referring item or referring item's ID.
628
+ * @param relationshipAttribute - The property that contains the references to the referenced items.
629
+ * @param options - Options for querying referenced data items.
630
+ * @permissionScope Read Data Items
631
+ * @permissionScopeId SCOPE.DC-DATA.READ
632
+ * @applicableIdentity APP
633
+ */
634
+ export declare function queryReferenced(dataCollectionId: string, holdingItem: WixDataItem | string, relationshipAttribute: string, options?: WixDataReadWithProjectionOptions & {
635
+ order?: 'asc' | 'desc';
636
+ skip?: number;
637
+ limit?: number;
638
+ }): Promise<WixDataResult>;
639
+ /**
640
+ * Creates a filter to be used with queries and aggregations.
641
+ *
642
+ * The `filter()` function builds a filter to be applied to a query or an aggregation, and returns a `WixDataFilter` object.
643
+ * The returned object contains the filter definition and can be combined with query builder using `and()`, `or()` and `not()` functions.
644
+ *
645
+ * When working with Wix App Collections, check which fields can be used in a filter.
646
+ *
647
+ * @public
648
+ * @documentationMaturity preview
649
+ */
650
+ export declare function filter(): WixDataFilter;
651
+ export { WixDataReadOptions, WixDataReadWithProjectionOptions, WixDataOptions, WixDataUpdateOptions, WixDataItem, WixDataBulkResult, WixDataBulkError, WixDataQuery, WixDataPatch, WixDataAggregate, QueryBase, WixDataFilter, WixDataResult, };