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