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