@wix/wix-data-items-sdk 1.0.223 → 1.0.225
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.
- package/build/cjs/src/data-v2-data-item-items.universal.d.ts +76 -165
- package/build/cjs/src/data-v2-data-item-items.universal.js +76 -165
- package/build/cjs/src/data-v2-data-item-items.universal.js.map +1 -1
- package/build/es/src/data-v2-data-item-items.universal.d.ts +76 -165
- package/build/es/src/data-v2-data-item-items.universal.js +76 -165
- package/build/es/src/data-v2-data-item-items.universal.js.map +1 -1
- package/package.json +4 -4
|
@@ -12,11 +12,7 @@ import { WixDataUpdateOptions, WixDataReadOptions, WixDataOptions, WixDataAggreg
|
|
|
12
12
|
* existing ID in the collection. Meaning, `insert()` cannot overwrite an
|
|
13
13
|
* existing item in the collection.
|
|
14
14
|
*
|
|
15
|
-
* Calling the `insert()` method 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.
|
|
15
|
+
* Calling the `insert()` method triggers the [`beforeInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-insert) and [`afterInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-insert) hooks if they have been defined.
|
|
20
16
|
*
|
|
21
17
|
* When inserting an item into a collection that has a reference field, set the
|
|
22
18
|
* value of the reference field to the referenced item's `_id` value or the entire referenced item object.
|
|
@@ -31,21 +27,15 @@ import { WixDataUpdateOptions, WixDataReadOptions, WixDataOptions, WixDataAggreg
|
|
|
31
27
|
* added, the `_createdDate` and `_updatedDate` are the same.
|
|
32
28
|
*
|
|
33
29
|
* Any valid JavaScript object can be added as a property value. The `insert()`
|
|
34
|
-
* method maintains the structure of the specified object. For example, objects that contain nested objects,
|
|
30
|
+
* method 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
31
|
*
|
|
36
|
-
* The maximum size of an item that you can add to a collection is 500kb.
|
|
37
32
|
*
|
|
38
33
|
* > **Notes:**
|
|
39
|
-
* > -
|
|
40
|
-
*
|
|
41
|
-
* > - When creating a
|
|
42
|
-
* >
|
|
43
|
-
* >
|
|
44
|
-
* > - If there is a pre-existing item in a Single Item Collection, the
|
|
45
|
-
* > `insert()` method will not run. To update or change an item in a
|
|
46
|
-
* > Single Item Collection see the `update()` and `save()` methods.
|
|
47
|
-
* > - The `insert()` method does not support multi-reference fields. For
|
|
48
|
-
* > multi-reference fields, use `insertReference()`.
|
|
34
|
+
* > - The maximum size of an item that you can add to a collection is 500kb.
|
|
35
|
+
* > - If an item's `_id` property value is set to `null` or an empty string, an error is thrown.
|
|
36
|
+
* > - When creating a [single-item collection](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection), an item with the system field `_id` is pre-inserted into the collection. [Single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection) may contain only one item.
|
|
37
|
+
* > - If there is a pre-existing item in a [single-item collection](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection), the `insert()` method will not run. To update or change an item in a single-item collection see the `update()` and `save()` methods.
|
|
38
|
+
* > - The `insert()` method does not support multi-reference fields. For multi-reference fields, use `insertReference()`.
|
|
49
39
|
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling `insert()` fails and issues an error.
|
|
50
40
|
* @public
|
|
51
41
|
* @param dataCollectionId - ID of the collection item belongs to.
|
|
@@ -65,8 +55,7 @@ export declare function insert(dataCollectionId: string, item: Partial<WixDataIt
|
|
|
65
55
|
* the specified collection. The Promise is rejected if the current user does not
|
|
66
56
|
* have update permissions for the collection.
|
|
67
57
|
*
|
|
68
|
-
* Calling the `update()` method triggers the `beforeUpdate()` and `afterUpdate()`
|
|
69
|
-
* hooks if they have been defined.
|
|
58
|
+
* Calling the `update()` method triggers the [`beforeUpdate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-update) and [`afterUpdate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-update) hooks if they have been defined.
|
|
70
59
|
*
|
|
71
60
|
* The `update()` method compares the `_id` property of the specified item
|
|
72
61
|
* with the `_id` property values of the items in the specified collection. If
|
|
@@ -78,12 +67,9 @@ export declare function insert(dataCollectionId: string, item: Partial<WixDataIt
|
|
|
78
67
|
*
|
|
79
68
|
* Any valid JavaScript object can be used as a property value. The `update()`
|
|
80
69
|
* method maintains the structure of the specified object. For example,
|
|
81
|
-
* objects that contain nested objects,
|
|
70
|
+
* objects that contain nested objects, arrays, or arrays with nested objects
|
|
82
71
|
* are all added to the collection as defined.
|
|
83
72
|
*
|
|
84
|
-
* Use the `options` parameter to run `update()` from backend code without
|
|
85
|
-
* checking for permissions or without its registered hooks.
|
|
86
|
-
*
|
|
87
73
|
* When updating an item in a collection that has a reference field, set the
|
|
88
74
|
* value of the reference field to the referenced item's `_id` value or the
|
|
89
75
|
* entire referenced item object.
|
|
@@ -123,24 +109,20 @@ export declare function update(dataCollectionId: string, item: WixDataItem, opti
|
|
|
123
109
|
* If none of the items in the collection contain that `_id` value, the
|
|
124
110
|
* specified item does not have an `_id` property, or if the specified item's
|
|
125
111
|
* id property is `undefined`, `save()` uses `insert()` to add the specified
|
|
126
|
-
* item to the collection. This triggers the `beforeInsert()` and
|
|
127
|
-
* `afterInsert()` hooks if they have been defined.
|
|
112
|
+
* item to the collection. This triggers the [`beforeInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-insert) and
|
|
113
|
+
* [`afterInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-insert) hooks if they have been defined.
|
|
128
114
|
*
|
|
129
|
-
* Use the `options` parameter to run `save()` from backend code without
|
|
130
|
-
* checking for permissions or without its registered hooks.
|
|
131
115
|
*
|
|
132
116
|
* When saving an item to a collection that has a reference field, set the
|
|
133
117
|
* value of the reference field to the referenced item's `_id` value or the
|
|
134
118
|
* entire referenced item object.
|
|
135
119
|
*
|
|
136
|
-
* The maximum size of an item that you can save to a collection is 500kb.
|
|
137
|
-
*
|
|
138
120
|
* > **Notes:**
|
|
139
|
-
* > -
|
|
140
|
-
* >
|
|
141
|
-
* > - The `save()` method does not support multi-reference fields. For
|
|
142
|
-
* > multi-reference fields, use `insertReference() `or `replaceReferences()`.
|
|
121
|
+
* > - The maximum size of an item that you can save to a collection is 500kb.
|
|
122
|
+
* > - If an item's `_id` property value is set to null or an empty string, an error is thrown.
|
|
123
|
+
* > - The `save()` method does not support multi-reference fields. For multi-reference fields, use `insertReference() `or `replaceReferences()`.
|
|
143
124
|
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling `save()` fails and issues an error.
|
|
125
|
+
*
|
|
144
126
|
* @public
|
|
145
127
|
* @documentationMaturity preview
|
|
146
128
|
* @requiredField dataCollectionId
|
|
@@ -164,23 +146,14 @@ export declare function save(dataCollectionId: string, item: Partial<WixDataItem
|
|
|
164
146
|
* referenced item is returned. To return the values of the referenced items
|
|
165
147
|
* use `query()` and `include()`.
|
|
166
148
|
*
|
|
167
|
-
* If the `get()` method is passed the ID of a hidden item, it returns null.
|
|
149
|
+
* If the `get()` method is passed the ID of [a hidden item](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection), it returns null.
|
|
168
150
|
*
|
|
169
|
-
* Calling the `get()` method triggers the `beforeGet()` and `afterGet()`
|
|
170
|
-
* hooks if they have been defined.
|
|
171
|
-
*
|
|
172
|
-
* Use the `options` parameter to run `get()` from backend code without
|
|
173
|
-
* checking for permissions or without its registered hooks.
|
|
151
|
+
* Calling the `get()` method triggers the [`beforeGet()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-get) and [`afterGet()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-get) hooks if they have been defined.
|
|
174
152
|
*
|
|
175
153
|
* > **Notes:**
|
|
176
|
-
* > - When using the `query()` or `get()` methods or another data retrieval
|
|
177
|
-
* >
|
|
178
|
-
*
|
|
179
|
-
* > Eventual Consistency for more information. To solve this problem, you
|
|
180
|
-
* > can use the `setTimeout()` method to delay retrieving data following
|
|
181
|
-
* > any changes to your database collection.
|
|
182
|
-
* > - An `itemId` is required to retrieve an item even from a single-item
|
|
183
|
-
* > collection.
|
|
154
|
+
* > - When using the `query()` or `get()` methods or another data retrieval method immediately following a change to your database collection, the data retrieved may not contain your most recent changes. Learn more about [Wix Data and Eventual Consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). To solve this, you can use the `setTimeout()` method to delay retrieving data following any changes to your database collection.
|
|
155
|
+
* > - An `itemId` is required to retrieve an item even from a [single-item collection](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
156
|
+
*
|
|
184
157
|
* @param dataCollectionId - ID of the collection item belongs to.
|
|
185
158
|
* @param itemId - ID of the data item to retrieve.
|
|
186
159
|
* @param options - Options to use when processing this operation.
|
|
@@ -201,19 +174,11 @@ export declare function get(dataCollectionId: string, itemId: string, options?:
|
|
|
201
174
|
* rejected if the current user does not have "delete" permissions for the
|
|
202
175
|
* collection.
|
|
203
176
|
*
|
|
204
|
-
* Calling the `remove()` method triggers the `beforeRemove()` and
|
|
205
|
-
* `afterRemove()` hooks if they have been defined.
|
|
177
|
+
* Calling the `remove()` method triggers the [`beforeRemove()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-remove) and [`afterRemove()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-remove) hooks if they have been defined.
|
|
206
178
|
*
|
|
207
|
-
* Use the `options` parameter to run `remove()` from backend code without
|
|
208
|
-
* checking for permissions or without its registered hooks.
|
|
209
179
|
*
|
|
210
|
-
* > **
|
|
211
|
-
*
|
|
212
|
-
* > items in collections referenced by the specified item. For example,
|
|
213
|
-
* > suppose you have a **Movies** collection with an **Actors** field that
|
|
214
|
-
* > contains multiple references to items in a **People** collection. Removing
|
|
215
|
-
* > an item in the **Movies** collection also clears the data in the
|
|
216
|
-
* > corresponding multiple-item reference fields in the **People** collection.
|
|
180
|
+
* > **Note:** The `remove()` method also clears multiple-item reference fields for items in collections referenced by the specified item. For example, suppose you have a **Movies** collection with an **Actors** field that contains multiple references to items in a **People** collection. Removing an item in the **Movies** collection also clears the data in the corresponding multiple-item reference fields in the **People** collection.
|
|
181
|
+
*
|
|
217
182
|
* @param dataCollectionId - ID of the collection that contains the item.
|
|
218
183
|
* @param itemId - ID of the item to remove.
|
|
219
184
|
* @param options - Object containing options to use when processing this operation.
|
|
@@ -231,19 +196,10 @@ export declare function remove(dataCollectionId: string, itemId: string, options
|
|
|
231
196
|
* The `truncate()` method returns a Promise that resolves after all items
|
|
232
197
|
* have been removed from the specified collection.
|
|
233
198
|
*
|
|
234
|
-
* `truncate()` runs when
|
|
235
|
-
* - The current user is the site owner.
|
|
236
|
-
* - The request is performed in backend code with a `suppressAuth` options
|
|
237
|
-
* value of `true`.
|
|
199
|
+
* `truncate()` runs when the current user is the site owner, or when the method is called with [elevated permissions](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-elevated-permissions).
|
|
238
200
|
*
|
|
239
|
-
*
|
|
201
|
+
* > **Note:** `truncate()` also clears multiple-item reference fields in collections referenced by the specified collection. For example, suppose you have a **Movies** collection with an **Actors** field that contains multiple references to items in a People collection. Truncating the **Movies** collection also clears the data in the corresponding multiple-item reference field in the People collection.
|
|
240
202
|
*
|
|
241
|
-
* > **Note:** `truncate()` also clears multiple-item reference fields in
|
|
242
|
-
* > collections referenced by the specified collection. For example, suppose you
|
|
243
|
-
* > have a **Movies** collection with an **Actors** field that contains multiple
|
|
244
|
-
* > references to items in a People collection. Truncating the **Movies**
|
|
245
|
-
* > collection also clears the data in the corresponding multiple-item reference
|
|
246
|
-
* > field in the People collection.
|
|
247
203
|
* @public
|
|
248
204
|
* @documentationMaturity preview
|
|
249
205
|
* @requiredField dataCollectionId
|
|
@@ -259,15 +215,10 @@ export declare function truncate(dataCollectionId: string): Promise<void>;
|
|
|
259
215
|
* have been added to the specified collection. The Promise is rejected if the
|
|
260
216
|
* current user does not have "create" permissions for the collection. Items
|
|
261
217
|
* are skipped if they include an `_id` property whose value matches an
|
|
262
|
-
* existing ID in the collection.
|
|
218
|
+
* existing ID in the collection. This means that `bulkInsert()` cannot overwrite an
|
|
263
219
|
* existing item in the collection.
|
|
264
220
|
*
|
|
265
|
-
* Calling the `bulkInsert()` method triggers the `beforeInsert()` and
|
|
266
|
-
* `afterInsert()` hooks for each item that is inserted if the hooks have been
|
|
267
|
-
* defined.
|
|
268
|
-
*
|
|
269
|
-
* Use the options parameter to run `bulkInsert()` from backend code without
|
|
270
|
-
* checking for permissions or without its registered hooks.
|
|
221
|
+
* Calling the `bulkInsert()` method triggers the [`beforeInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-insert) and [`afterInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-insert) events for each item that is inserted, if these events have been defined.
|
|
271
222
|
*
|
|
272
223
|
* When inserting items into a collection that has a reference field, set the
|
|
273
224
|
* values of the reference fields to the referenced item's `_id` value or the
|
|
@@ -285,19 +236,17 @@ export declare function truncate(dataCollectionId: string): Promise<void>;
|
|
|
285
236
|
*
|
|
286
237
|
* Any valid JavaScript object can be added as a property value. The
|
|
287
238
|
* `bulkInsert()` method maintains the structure of the specified object. For
|
|
288
|
-
* example, objects that contain nested objects,
|
|
239
|
+
* example, objects that contain nested objects, arrays, or arrays with nested
|
|
289
240
|
* objects are all added to the collection as defined.
|
|
290
241
|
*
|
|
291
|
-
* The maximum size of an item that you can add to a collection is 500kb.
|
|
292
242
|
*
|
|
293
243
|
* > **Notes:**
|
|
294
|
-
* > -
|
|
295
|
-
* >
|
|
244
|
+
* > - The maximum size of an item that you can add to a collection is 500kb.
|
|
245
|
+
* > - If an item's `_id` property value is set to `null` or an empty string, an error is thrown.
|
|
296
246
|
* > - Bulk operations are limited to 1000 items per method call.
|
|
297
|
-
* > - The `bulkInsert()` method is not supported for
|
|
298
|
-
* > - The `bulkInsert()` method does not support multi-reference fields. For
|
|
299
|
-
* >
|
|
300
|
-
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling bulkInsert() fails and issues an error.
|
|
247
|
+
* > - The `bulkInsert()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
248
|
+
* > - The `bulkInsert()` method does not support multi-reference fields. For multi-reference fields, use `insertReference()`.
|
|
249
|
+
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling `bulkInsert()` fails and issues an error.
|
|
301
250
|
* @public
|
|
302
251
|
* @documentationMaturity preview
|
|
303
252
|
* @requiredField dataCollectionId
|
|
@@ -319,39 +268,32 @@ export declare function bulkInsert(dataCollectionId: string, items: Partial<WixD
|
|
|
319
268
|
* existing ID in the collection. Meaning, `bulkUpdate()` cannot add new items
|
|
320
269
|
* into the collection.
|
|
321
270
|
*
|
|
322
|
-
* Calling the `bulkUpdate()` method triggers the `beforeUpdate()` and
|
|
323
|
-
* `afterUpdate()` hooks for each item that is updated if the hooks have been
|
|
324
|
-
* defined.
|
|
271
|
+
* Calling the `bulkUpdate()` method triggers the [`beforeUpdate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-udpate) and [`afterUpdate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-update) hooks for each item that is updated if the hooks have been defined.
|
|
325
272
|
*
|
|
326
|
-
* The `bulkUpdate()` method compares the `_id` property of the specified
|
|
327
|
-
* items with the `_id` property values of the items in the specified
|
|
328
|
-
* collection.
|
|
273
|
+
* The `bulkUpdate()` method compares the `_id` property of the specified items with the `_id` property values of the items in the specified collection.
|
|
329
274
|
*
|
|
330
275
|
* > **Warning:**
|
|
331
|
-
* >
|
|
332
|
-
*
|
|
333
|
-
*
|
|
276
|
+
* > If an existing item in the specified collection matches the `_id` of the specified item, `bulkUpdate()` replaces the existing item's property values with the ones in the specified item. If the existing item had properties with values and those properties are not included in the specified item, the values in those properties are lost.
|
|
277
|
+
*
|
|
278
|
+
* The item's `_updatedDate` property is also updated to the current date.
|
|
334
279
|
*
|
|
335
280
|
* Any valid JavaScript object can be used as a property value. The
|
|
336
281
|
* `bulkUpdate()` method maintains the structure of the specified object. For
|
|
337
|
-
* example, objects that contain nested objects,
|
|
282
|
+
* example, objects that contain nested objects, arrays, or arrays with nested
|
|
338
283
|
* objects are all added to the collection as defined.
|
|
339
284
|
*
|
|
340
|
-
* Use the options parameter to run `bulkUpdate()` from backend code without
|
|
341
|
-
* checking for permissions or without its registered hooks.
|
|
342
285
|
*
|
|
343
286
|
* When updating items in a collection that has a reference field, set the
|
|
344
287
|
* values of the reference field to the referenced item's `_id` value or the
|
|
345
288
|
* entire referenced item object.
|
|
346
289
|
*
|
|
347
|
-
* The maximum size of an item that you can update in a collection is 500kb.
|
|
348
|
-
*
|
|
349
290
|
* > **Notes:**
|
|
291
|
+
* > - The maximum size of an item that you can update in a collection is 500kb.
|
|
350
292
|
* > - Bulk operations are limited to 1000 items per method call.
|
|
351
|
-
* > - The `bulkUpdate()` method is not supported for
|
|
352
|
-
* > - The `bulkUpdate()` method does not support multi-reference fields. For
|
|
353
|
-
* >
|
|
354
|
-
*
|
|
293
|
+
* > - The `bulkUpdate()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
294
|
+
* > - The `bulkUpdate()` method does not support multi-reference fields. For multi-reference fields, use `replaceReferences()` or `insertReference()`.
|
|
295
|
+
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling `bulkUpdate()` fails and issues an error.
|
|
296
|
+
*
|
|
355
297
|
* @public
|
|
356
298
|
* @documentationMaturity preview
|
|
357
299
|
* @requiredField dataCollectionId
|
|
@@ -383,27 +325,20 @@ export declare function bulkUpdate(dataCollectionId: string, items: WixDataItem[
|
|
|
383
325
|
* - If none of the items in the collection contain that `_id` value, the
|
|
384
326
|
* specified item does not have an `_id` property, or if the specified item's
|
|
385
327
|
* `_id` property is `undefined`, `bulkSave()` uses `insert()` to add the
|
|
386
|
-
* specified item into the collection. This triggers the `beforeInsert()` and
|
|
387
|
-
* `afterInsert()` hooks for that item if they have been defined.
|
|
388
|
-
*
|
|
389
|
-
* Use the `options` parameter to run `bulkSave()` from backend code without
|
|
390
|
-
* checking for permissions or without its registered hooks.
|
|
328
|
+
* specified item into the collection. This triggers the [`beforeInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-insert) and [`afterInsert()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-insert) hooks for that item if they have been defined.
|
|
391
329
|
*
|
|
392
330
|
* When saving items to a collection that has a reference field, set the values
|
|
393
331
|
* of the reference fields to the referenced item's `_id` value or the entire
|
|
394
332
|
* referenced item object.
|
|
395
333
|
*
|
|
396
|
-
* The maximum size of an item that you can save to a collection is 500kb.
|
|
397
|
-
*
|
|
398
334
|
* > **Notes:**
|
|
399
|
-
* > -
|
|
400
|
-
* >
|
|
335
|
+
* > - The maximum size of an item that you can save to a collection is 500kb.
|
|
336
|
+
* > - If an item's `_id` property value is set to null or an empty string, an error is thrown.
|
|
401
337
|
* > - Bulk operations are limited to 1000 items per method call.
|
|
402
|
-
* > - The `bulkSave()` method is not supported for
|
|
403
|
-
* > - The `bulkSave()` method does not support multi-reference fields. For
|
|
404
|
-
* >
|
|
405
|
-
*
|
|
406
|
-
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling bulkSave() fails and issues an error.
|
|
338
|
+
* > - The `bulkSave()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
339
|
+
* > - The `bulkSave()` method does not support multi-reference fields. For multi-reference fields, use `replaceReferences()` or `insertReference()`.
|
|
340
|
+
* > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling `bulkSave()` fails and issues an error.
|
|
341
|
+
*
|
|
407
342
|
* @public
|
|
408
343
|
* @documentationMaturity preview
|
|
409
344
|
* @requiredField dataCollectionId
|
|
@@ -418,19 +353,9 @@ export declare function bulkSave(dataCollectionId: string, items: Partial<WixDat
|
|
|
418
353
|
/**
|
|
419
354
|
* Removes a number of items from a collection.
|
|
420
355
|
*
|
|
421
|
-
* The `bulkRemove()` method returns a Promise that resolves after the items
|
|
422
|
-
* have been removed from the specified collection. The Promise is rejected if
|
|
423
|
-
* the current user does not have "delete" permissions for the collection. If
|
|
424
|
-
* the delete permissions for the collection are set to Site member author, the
|
|
425
|
-
* only items that are deleted are those for which the current user is the
|
|
426
|
-
* owner. All other items are skipped.
|
|
427
|
-
*
|
|
428
|
-
* Calling the `bulkRemove()` method triggers the `beforeRemove()` and
|
|
429
|
-
* `afterRemove()` hooks for each item that is deleted if the hooks have been
|
|
430
|
-
* defined.
|
|
356
|
+
* The `bulkRemove()` method returns a Promise that resolves after the items have been removed from the specified collection. The Promise is rejected if the current user does not have "delete" permissions for the collection. If the delete permissions for the collection are assigned to [**Item's creator**](https://support.wix.com/en/article/cms-collection-permissions-overview#set-custom-permissions-for-more-access-control), the only items that are deleted are those for which the current user is the owner. All other items are skipped.
|
|
431
357
|
*
|
|
432
|
-
*
|
|
433
|
-
* checking for permissions or without its registered hooks.
|
|
358
|
+
* Calling the `bulkRemove()` method triggers the [`beforeRemove()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-remove) and [`afterRemove()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-remove) hooks for each item that is deleted if the hooks have been defined.
|
|
434
359
|
*
|
|
435
360
|
* > **Notes:**
|
|
436
361
|
* > - The `bulkRemove()` method also clears multiple-item reference fields
|
|
@@ -440,6 +365,7 @@ export declare function bulkSave(dataCollectionId: string, items: Partial<WixDat
|
|
|
440
365
|
* > Removing items in the **Movies** collection also clears the data in the
|
|
441
366
|
* > corresponding multiple-item reference fields in the People collection.
|
|
442
367
|
* > - Bulk operations are limited to 1000 items per method call.
|
|
368
|
+
*
|
|
443
369
|
* @public
|
|
444
370
|
* @documentationMaturity preview
|
|
445
371
|
* @requiredField dataCollectionId
|
|
@@ -456,10 +382,8 @@ export declare function bulkRemove(dataCollectionId: string, itemIds: string[],
|
|
|
456
382
|
*
|
|
457
383
|
* The `isReferenced()` method returns a Promise that resolves to true if the referring item contains a reference to the referenced item in the specified field. The Promise is rejected if the current user does not have read permissions for the collection.
|
|
458
384
|
*
|
|
459
|
-
*
|
|
385
|
+
* > **Note:** The `isReferenced()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
460
386
|
*
|
|
461
|
-
* > **Note:** The `isReferenced()` method is not supported for Single Item
|
|
462
|
-
* > Collections.
|
|
463
387
|
* @public
|
|
464
388
|
* @documentationMaturity preview
|
|
465
389
|
* @requiredField dataCollectionId
|
|
@@ -486,8 +410,6 @@ export declare function isReferenced(dataCollectionId: string, field: string, re
|
|
|
486
410
|
* specified property. The Promise is rejected if the current user does not
|
|
487
411
|
* have update permissions for the collection.
|
|
488
412
|
*
|
|
489
|
-
* Calling the `insertReference()` method does not trigger any hooks.
|
|
490
|
-
*
|
|
491
413
|
* > **Notes:**
|
|
492
414
|
* > - The `insertReference()` method only applies to multi-reference fields.
|
|
493
415
|
* > - The `insertReference()` method is not supported for Single Item
|
|
@@ -515,10 +437,8 @@ export declare function insertReference(dataCollectionId: string, field: string,
|
|
|
515
437
|
* in the referring item. The Promise is rejected if the current user does not
|
|
516
438
|
* have update permissions for the collection.
|
|
517
439
|
*
|
|
518
|
-
*
|
|
440
|
+
* > **Note:** The `removeReference()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
519
441
|
*
|
|
520
|
-
* > **Note:** The `removeReference()` method is not supported for Single
|
|
521
|
-
* > Item Collections.
|
|
522
442
|
* @public
|
|
523
443
|
* @documentationMaturity preview
|
|
524
444
|
* @requiredField dataCollectionId
|
|
@@ -543,10 +463,9 @@ export declare function removeReference(dataCollectionId: string, field: string,
|
|
|
543
463
|
* rejected if the current user does not have update permissions for the
|
|
544
464
|
* collection.
|
|
545
465
|
*
|
|
546
|
-
* Calling the `replaceReferences()` method does not trigger any hooks.
|
|
547
466
|
*
|
|
548
|
-
* > **Note:** The `replaceReferences()` method is not supported for
|
|
549
|
-
*
|
|
467
|
+
* > **Note:** The `replaceReferences()` method is not supported for [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
468
|
+
*
|
|
550
469
|
* @public
|
|
551
470
|
* @documentationMaturity preview
|
|
552
471
|
* @requiredField dataCollectionId
|
|
@@ -567,31 +486,25 @@ export declare function bulkPatch(dataCollectionId: string, itemIds: string[]):
|
|
|
567
486
|
/**
|
|
568
487
|
* Creates a query to retrieve items from a database collection.
|
|
569
488
|
*
|
|
570
|
-
* The `query()` method builds a query to retrieve data items from a collection and returns a `WixDataQuery` object, which contains the query definition.
|
|
571
|
-
*
|
|
572
|
-
* You can refine the query by chaining `WixDataQuery` methods onto the query. `WixDataQuery` methods enable you to sort, filter, and control the results that `query()` returns.
|
|
489
|
+
* The `query()` method builds a query to retrieve data items from a collection and returns a `WixDataQuery` object, which contains the query definition. You can refine the query by chaining [`WixDataQuery` methods](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-query/introduction) onto the query. `WixDataQuery` methods enable you to sort, filter, and control the query results.
|
|
573
490
|
*
|
|
574
|
-
*
|
|
491
|
+
* The methods chained to `query()` are applied in the order they are called. For example, if you sort by an `age` field in ascending order and then by a `name` field in descending order, the results are sorted first by the age of the items. If there are multiple results with the same age, they are further sorted by name in descending order, per age value.
|
|
575
492
|
*
|
|
576
|
-
*
|
|
493
|
+
* Finally, to run the query, chain [`find()`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-query/find) or [`distinct()`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-query/distinct) as the last method.
|
|
577
494
|
*
|
|
578
495
|
* The `query()` method runs with the following `WixDataQuery` defaults that you can override:
|
|
579
|
-
* - `skip`: 0
|
|
580
|
-
* - `limit`: 50
|
|
496
|
+
* - `skip`: `0`
|
|
497
|
+
* - `limit`: `50`
|
|
581
498
|
* - `descending`: by `_createdDate`
|
|
582
|
-
* - `include`: none
|
|
583
|
-
*
|
|
584
|
-
* If the collection that you are querying has references to other collections, by default the data from referenced collections is not retrieved. To retrieve data from the referenced items, specify them using the `include()` method.
|
|
499
|
+
* - `include`: `none`
|
|
585
500
|
*
|
|
586
501
|
* > **Notes**:
|
|
587
|
-
* > - When calling `query()` following an update to your collection, the data retrieved might not contain the most recent changes. If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
588
|
-
* > - Items marked as hidden are not retrieved.
|
|
589
|
-
*
|
|
590
|
-
* When
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
* - Can be sorted and filtered
|
|
594
|
-
* - Read-only: Check which fields can be used in a query.
|
|
502
|
+
* > - When calling `query()` immediately following an update to your collection, the data retrieved might not contain the most recent changes. If you need the most up-to-date data, set the `options.consistentRead` parameter of the [`find()`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-query/find) or [`distinct()`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-query/distinct) methods to `true`. Learn more about [Wix Data and Eventual Consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency).
|
|
503
|
+
* > - Items marked [in the CMS as hidden](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection) are not retrieved.
|
|
504
|
+
* > - If the collection that you are querying has references to other collections, by default the data from referenced collections is not retrieved. To retrieve data from the referenced items, specify them using the `include()` method.
|
|
505
|
+
* > - When querying [Wix app collections](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code), make sure the fields you use to refine your query support the intended operations. Learn more about [querying by Wix app collection fields](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections).
|
|
506
|
+
*
|
|
507
|
+
*
|
|
595
508
|
* @public
|
|
596
509
|
* @documentationMaturity preview
|
|
597
510
|
* @requiredField dataCollectionId
|
|
@@ -607,16 +520,15 @@ export declare function query(dataCollectionId: string): WixDataQuery;
|
|
|
607
520
|
* The `aggregate()` method builds an aggregation on the specified collection and returns a `WixDataAggregate` object.
|
|
608
521
|
*
|
|
609
522
|
* An aggregation enables you to perform certain calculations on your collection data, or on groups of items that you define, to retrieve meaningful summaries.
|
|
610
|
-
* You can also add paging, filtering, and sorting preferences to your aggregation to retrieve exactly what you need.
|
|
611
523
|
*
|
|
612
|
-
*
|
|
524
|
+
* You can also add paging, filtering, and sorting preferences to your aggregation by chaining [`WixDataAggregate`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-aggregate/introduction) methods. The returned object contains the aggregate definition.
|
|
613
525
|
*
|
|
614
|
-
*
|
|
526
|
+
* Finally, to run the aggregation, chain [`run()`](https://dev.wix.com/docs/sdk/backend-modules/data/items-new/wix-data-aggregate/run) as the last method.
|
|
615
527
|
*
|
|
616
528
|
* The `aggregate()` method runs with the following defaults that you can override:
|
|
617
529
|
*
|
|
618
|
-
* + `skip`
|
|
619
|
-
* + `limit
|
|
530
|
+
* + `skip`: `0`
|
|
531
|
+
* + `limit`: `50`
|
|
620
532
|
*
|
|
621
533
|
* @public
|
|
622
534
|
* @documentationMaturity preview
|
|
@@ -637,10 +549,9 @@ export declare function aggregate(dataCollectionId: string): WixDataAggregate;
|
|
|
637
549
|
* The `queryReferenced()` method returns a Promise that resolves to the full items referenced in the specified property of the item from the specified collection. The Promise is rejected if the current user does not have read permissions for the specified collection or the collection containing the referenced items.
|
|
638
550
|
*
|
|
639
551
|
* > **Notes**:
|
|
640
|
-
* > - Calling `queryReferenced()` does not trigger any hooks.
|
|
641
552
|
* > - You can only call `queryReferenced()` for [multi-reference fields](https://support.wix.com/en/article/about-referencing-multiple-items-in-one-field).
|
|
642
553
|
* > - This method does not support [single-item collections](https://support.wix.com/en/article/cms-adding-and-setting-up-a-single-item-collection).
|
|
643
|
-
* > - When calling `queryReferenced()` following an update to your collection, the data retrieved [may not contain the most recent changes](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
554
|
+
* > - When calling `queryReferenced()` immediately following an update to your collection, the data retrieved [may not contain the most recent changes](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). If you need the most up-to-date data, set `options.consistentRead` to `true`.
|
|
644
555
|
*
|
|
645
556
|
* Learn more about [querying items that reference other items](https://support.wix.com/en/article/including-referenced-data-when-filtering).
|
|
646
557
|
* @public
|
|
@@ -666,7 +577,7 @@ export declare function queryReferenced(dataCollectionId: string, referringItem:
|
|
|
666
577
|
*
|
|
667
578
|
* The `filter()` method builds a filter to be applied to a query or an aggregation. It returns a `WixDataFilter` object, which can be used with other filter methods such as `and()`, `or()` and `not()`, to create complex filter definitions.
|
|
668
579
|
*
|
|
669
|
-
* When working with [Wix app collections](https://
|
|
580
|
+
* When working with [Wix app collections](https://dev.wix.com/docs/develop-websites/articles/databases/wix-data/collections/working-with-wix-app-collections-and-code), check which fields can be used in a filter.
|
|
670
581
|
*
|
|
671
582
|
* @public
|
|
672
583
|
* @documentationMaturity preview
|