@wix/ditto-codegen-public 1.0.162 → 1.0.164
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/dist/docs-output/api-docs/bookings-bookings-onBookingCanceled-doc.txt +169 -0
- package/dist/docs-output/api-docs/bookings-bookings-onBookingCreated-doc.txt +154 -0
- package/dist/docs-output/api-docs/crm-contacts-onContactCreated-doc.txt +87 -171
- package/dist/docs-output/api-docs/crm-contacts-onContactDeleted-doc.txt +58 -0
- package/dist/docs-output/api-docs/crm-contacts-onContactUpdated-doc.txt +99 -0
- package/dist/docs-output/api-docs/data-items-get-doc.txt +95 -54
- package/dist/docs-output/api-docs/data-items-insert-doc.txt +235 -43
- package/dist/docs-output/api-docs/data-items-onDataItemCreated-doc.txt +61 -0
- package/dist/docs-output/api-docs/data-items-onDataItemDeleted-doc.txt +58 -0
- package/dist/docs-output/api-docs/data-items-onDataItemUpdated-doc.txt +61 -0
- package/dist/docs-output/api-docs/data-items-query-doc.txt +507 -302
- package/dist/docs-output/api-docs/data-items-remove-doc.txt +120 -40
- package/dist/docs-output/api-docs/data-items-update-doc.txt +425 -46
- package/dist/docs-output/api-docs/ecom-cart-addToCart-doc.txt +488 -0
- package/dist/docs-output/api-docs/ecom-cart-createCart-doc.txt +518 -0
- package/dist/docs-output/api-docs/ecom-cart-createCheckout-doc.txt +155 -0
- package/dist/docs-output/api-docs/ecom-cart-deleteCart-doc.txt +92 -0
- package/dist/docs-output/api-docs/ecom-cart-getCart-doc.txt +376 -0
- package/dist/docs-output/api-docs/ecom-cart-onCartCreated-doc.txt +89 -80
- package/dist/docs-output/api-docs/ecom-cart-onCartUpdated-doc.txt +91 -81
- package/dist/docs-output/api-docs/ecom-cart-removeLineItemsFromCart-doc.txt +321 -0
- package/dist/docs-output/api-docs/ecom-cart-updateCart-doc.txt +539 -0
- package/dist/docs-output/api-docs/ecom-checkout-addToCheckout-doc.txt +1005 -0
- package/dist/docs-output/api-docs/ecom-checkout-createCheckout-doc.txt +1641 -0
- package/dist/docs-output/api-docs/ecom-checkout-getCheckout-doc.txt +1027 -0
- package/dist/docs-output/api-docs/ecom-checkout-onCheckoutCompleted-doc.txt +151 -0
- package/dist/docs-output/api-docs/ecom-checkout-onCheckoutCreated-doc.txt +150 -0
- package/dist/docs-output/api-docs/ecom-checkout-onCheckoutUpdated-doc.txt +150 -0
- package/dist/docs-output/api-docs/ecom-checkout-removeLineItemsFromCheckout-doc.txt +879 -0
- package/dist/docs-output/api-docs/ecom-checkout-updateCheckout-doc.txt +1011 -0
- package/dist/docs-output/api-docs/ecom-currentCart-getCurrentCart-doc.txt +368 -322
- package/dist/docs-output/api-docs/ecom-currentCart-updateCurrentCart-doc.txt +506 -321
- package/dist/docs-output/api-docs/ecom-orders-bulkUpdateOrders-doc.txt +1040 -0
- package/dist/docs-output/api-docs/ecom-orders-cancelOrder-doc.txt +608 -0
- package/dist/docs-output/api-docs/ecom-orders-getOrder-doc.txt +926 -0
- package/dist/docs-output/api-docs/ecom-orders-onOrderCreated-doc.txt +245 -0
- package/dist/docs-output/api-docs/ecom-orders-onOrderUpdated-doc.txt +244 -0
- package/dist/docs-output/api-docs/ecom-orders-searchOrders-doc.txt +670 -0
- package/dist/docs-output/api-docs/ecom-orders-updateOrder-doc.txt +818 -0
- package/dist/docs-output/api-docs/search-wixSiteSearch-search-doc.txt +162 -0
- package/dist/docs-output/api-docs/stores-collections-addProductsToCollection-doc.txt +86 -0
- package/dist/docs-output/api-docs/stores-collections-createCollection-doc.txt +108 -0
- package/dist/docs-output/api-docs/stores-collections-getCollection-doc.txt +102 -0
- package/dist/docs-output/api-docs/stores-collections-queryCollections-doc.txt +209 -0
- package/dist/docs-output/api-docs/stores-collections-removeProductsFromCollection-doc.txt +86 -0
- package/dist/docs-output/api-docs/stores-collections-updateCollection-doc.txt +110 -0
- package/dist/docs-output/api-docs/stores-inventory-queryInventory-doc.txt +98 -0
- package/dist/docs-output/api-docs/stores-inventory-updateInventoryVariants-doc.txt +249 -0
- package/dist/docs-output/api-docs/stores-inventoryItemsV3-queryInventoryItems-doc.txt +236 -0
- package/dist/docs-output/api-docs/stores-inventoryItemsV3-updateInventoryItem-doc.txt +139 -0
- package/dist/docs-output/api-docs/stores-productsV3-createProduct-doc.txt +1697 -0
- package/dist/docs-output/api-docs/stores-productsV3-deleteProduct-doc.txt +73 -0
- package/dist/docs-output/api-docs/stores-productsV3-getProduct-doc.txt +933 -0
- package/dist/docs-output/api-docs/stores-productsV3-onProductCreated-doc.txt +794 -0
- package/dist/docs-output/api-docs/stores-productsV3-onProductDeleted-doc.txt +794 -0
- package/dist/docs-output/api-docs/stores-productsV3-onProductUpdated-doc.txt +794 -0
- package/dist/docs-output/api-docs/stores-productsV3-queryProducts-doc.txt +1051 -0
- package/dist/docs-output/api-docs/stores-productsV3-searchProducts-doc.txt +1144 -0
- package/dist/docs-output/api-docs/stores-productsV3-updateProduct-doc.txt +1730 -1600
- package/dist/docs-output/api-docs/stores-readOnlyVariantsV3-queryVariants-doc.txt +290 -0
- package/dist/docs-output/api-docs/stores-readOnlyVariantsV3-searchVariants-doc.txt +353 -0
- package/dist/out.js +24996 -553
- package/package.json +2 -2
- package/dist/docs-output/api-docs/data-items-onDataItemCreated.txt +0 -103
- package/dist/docs-output/api-docs/stores-product-onProductCreated-doc.txt +0 -118
- package/dist/docs-output/api-docs/stores-productV3-onProductCreated-doc.txt +0 -184
|
@@ -1,57 +1,436 @@
|
|
|
1
1
|
<data_items_update>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
- Update item properties without losing other field values
|
|
5
|
-
- Change item status or state in workflows (e.g., pending to approved)
|
|
6
|
-
- Update timestamps, counters, or computed fields
|
|
7
|
-
- Modify items conditionally based on current field values
|
|
8
|
-
- Bulk update item properties across multiple records
|
|
9
|
-
- Update items with references to other collections
|
|
10
|
-
- Maintain data integrity by updating related records
|
|
11
|
-
</use_cases>
|
|
12
|
-
|
|
13
|
-
<usage>
|
|
2
|
+
<description>
|
|
3
|
+
# Method name:
|
|
14
4
|
|
|
5
|
+
data.items.update(dataCollectionId: string, item: WixDataItem, options: WixDataUpdateOptions)
|
|
6
|
+
|
|
7
|
+
# Method Link:
|
|
8
|
+
|
|
9
|
+
https://dev.wix.com/docs/sdk/backend-modules/data/items/update
|
|
10
|
+
|
|
11
|
+
# Method Description:
|
|
12
|
+
|
|
13
|
+
Updates an item in a collection.
|
|
14
|
+
|
|
15
|
+
The `update()` method returns a Promise that resolves to the updated item from
|
|
16
|
+
the specified collection. The Promise is rejected if the current user does not
|
|
17
|
+
have update permissions for the collection.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
The `update()` method compares the `_id` property of the specified item
|
|
22
|
+
with the `_id` property values of the items in the specified collection. If
|
|
23
|
+
an item in the collection has that `_id` value, `update()` replaces the
|
|
24
|
+
item's property values with the ones in the specified item. If the existing
|
|
25
|
+
item had properties with values and those properties were not included in
|
|
26
|
+
the specified item, the values in those properties are lost. The item's
|
|
27
|
+
`_updatedDate` property is also updated to the current date.
|
|
28
|
+
|
|
29
|
+
Any valid JavaScript object can be used as a property value. The `update()`
|
|
30
|
+
method maintains the structure of the specified object. For example,
|
|
31
|
+
objects that contain nested objects, arrays, or arrays with nested objects
|
|
32
|
+
are all added to the collection as defined.
|
|
33
|
+
|
|
34
|
+
When updating an item in a collection that has a reference field, set the
|
|
35
|
+
value of the reference field to the referenced item's `_id` value or the
|
|
36
|
+
entire referenced item object.
|
|
37
|
+
|
|
38
|
+
The maximum size of an item that you can update in a collection is 500kb.
|
|
39
|
+
|
|
40
|
+
> **Notes:**
|
|
41
|
+
> - The specified item must include an `_id` property that already exists in the collection.
|
|
42
|
+
> - The `update()` method does not support multi-reference fields. For multi-reference fields, use `replaceReferences()` or `insertReference()`.
|
|
43
|
+
> - [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.
|
|
44
|
+
|
|
45
|
+
# Method Permissions:
|
|
46
|
+
|
|
47
|
+
- Write Data Items
|
|
48
|
+
|
|
49
|
+
# Method Permissions Scopes IDs:
|
|
50
|
+
|
|
51
|
+
- SCOPE.DC-DATA.WRITE
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Method Code Examples:
|
|
56
|
+
|
|
57
|
+
## Update an item with a specified ID in a collection
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
15
60
|
import { items } from "@wix/data";
|
|
16
61
|
|
|
17
62
|
async function updateItem() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
63
|
+
const toUpdate = {
|
|
64
|
+
"_id": "00001",
|
|
65
|
+
"title": "Mr.",
|
|
66
|
+
"first_name": "John",
|
|
67
|
+
"last_name": "Doe"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const updatedItem = await items.update("myCollection", toUpdate);
|
|
71
|
+
console.log(updatedItem); // See below
|
|
27
72
|
}
|
|
28
73
|
/* item is:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
74
|
+
*
|
|
75
|
+
* {
|
|
76
|
+
* "_id": "00001",
|
|
77
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
78
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
79
|
+
* "_updatedDate": "2017-05-24T12:33:18.938Z",
|
|
80
|
+
* "title": "Mr.",
|
|
81
|
+
* "first_name": "John",
|
|
82
|
+
* "last_name": "Doe"
|
|
83
|
+
* }
|
|
84
|
+
*/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## Get an item in a collection and update it
|
|
41
90
|
|
|
91
|
+
```javascript
|
|
92
|
+
import { items } from "@wix/data";
|
|
93
|
+
|
|
94
|
+
/* given existing item:
|
|
95
|
+
*
|
|
96
|
+
* {
|
|
97
|
+
* "_id": "00001",
|
|
98
|
+
* "title": "Mr.",
|
|
99
|
+
* "first_name": "John",
|
|
100
|
+
* "last_name": "Doe"
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
async function updateItem() {
|
|
106
|
+
const item = await items.get("myCollection", "00001");
|
|
107
|
+
item.last_name = "Smith"; // Updated last name
|
|
108
|
+
const updatedItem = await items.update("myCollection", item);
|
|
109
|
+
console.log(updatedItem); // See below
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* updated item:
|
|
113
|
+
*
|
|
114
|
+
* {
|
|
115
|
+
* "_id": "00001",
|
|
116
|
+
* "title": "Mr.",
|
|
117
|
+
* "first_name": "John",
|
|
118
|
+
* "last_name": "Smith"
|
|
119
|
+
* }
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Query an item in a collection and update it
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
import { items } from "@wix/data";
|
|
129
|
+
|
|
130
|
+
/* given existing item:
|
|
131
|
+
*
|
|
132
|
+
* {
|
|
133
|
+
* "_id": "00001",
|
|
134
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
135
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
136
|
+
* "_updatedDate": "2017-05-24T12:33:18.938Z",
|
|
137
|
+
* "title": "Mr.",
|
|
138
|
+
* "first_name": "John",
|
|
139
|
+
* "last_name": "Doe"
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
async function updateItem() {
|
|
145
|
+
const results = await items.query("myCollection")
|
|
146
|
+
.eq("first_name", "John")
|
|
147
|
+
.eq("last_name", "Doe")
|
|
148
|
+
.find();
|
|
149
|
+
|
|
150
|
+
if(results.items.length > 0) {
|
|
151
|
+
const item = results.items[0];
|
|
152
|
+
item.last_name = "Smith"; // Updated last name
|
|
153
|
+
const updatedItem = await items.update("myCollection", item);
|
|
154
|
+
console.log(updatedItem); // See below
|
|
155
|
+
} else {
|
|
156
|
+
// handle case where no matching items found
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/* updated item:
|
|
160
|
+
*
|
|
161
|
+
* {
|
|
162
|
+
* "_id": "00001",
|
|
163
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
164
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
165
|
+
* "_updatedDate": "2017-05-24T16:13:46.545Z",
|
|
166
|
+
* "title": "Mr.",
|
|
167
|
+
* "first_name": "John",
|
|
168
|
+
* "last_name": "Smith"
|
|
169
|
+
* }
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Update an item including a reference to another item using the referenced item's ID
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
import { items } from "@wix/data";
|
|
179
|
+
|
|
180
|
+
async function updateItem() {
|
|
181
|
+
const countryId = "id-of-usa-item";
|
|
182
|
+
|
|
183
|
+
const toUpdate = {
|
|
184
|
+
"_id": "00001",
|
|
185
|
+
"title": "Mr.",
|
|
186
|
+
"first_name": "John",
|
|
187
|
+
"last_name": "Doe",
|
|
188
|
+
"country": countryId
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const updatedItem = await items.update("myCollection", toUpdate);
|
|
192
|
+
console.log(updatedItem); // See below
|
|
193
|
+
}
|
|
194
|
+
/* item is:
|
|
195
|
+
*
|
|
196
|
+
* {
|
|
197
|
+
* "_id": "rifk4nrk-dj4o-djhe-oidk-fnoqw4oiglk4i",
|
|
198
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
199
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
200
|
+
* "_updatedDate": "2017-05-24T12:33:18.938Z",
|
|
201
|
+
* "title": "Mr.",
|
|
202
|
+
* "first_name": "John",
|
|
203
|
+
* "last_name": "Doe",
|
|
204
|
+
* "country": "id-of-usa-item"
|
|
205
|
+
* }
|
|
206
|
+
*/
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Update an item including a reference to another item using the referenced item
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
import { items } from "@wix/data";
|
|
213
|
+
|
|
214
|
+
async function updateItem() {
|
|
215
|
+
const countryItem = // Get country item
|
|
216
|
+
|
|
217
|
+
const toUpdate = {
|
|
218
|
+
"_id": "00001",
|
|
219
|
+
"title": "Mr.",
|
|
220
|
+
"first_name": "John",
|
|
221
|
+
"last_name": "Doe",
|
|
222
|
+
"country": countryItem
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const updatedItem = await items.update("myCollection", toUpdate);
|
|
226
|
+
console.log(updatedItem); // See below
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* item is:
|
|
230
|
+
*
|
|
231
|
+
* {
|
|
232
|
+
* "_id": "rifk4nrk-dj4o-djhe-oidk-fnoqw4oiglk4i",
|
|
233
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
234
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
235
|
+
* "_updatedDate": "2017-05-24T12:33:18.938Z",
|
|
236
|
+
* "title": "Mr.",
|
|
237
|
+
* "first_name": "John",
|
|
238
|
+
* "last_name": "Doe",
|
|
239
|
+
* "country": "id-of-usa-item"
|
|
240
|
+
* }
|
|
241
|
+
*/
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Update a collection using a custom function
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
import { items } from "@wix/data";
|
|
248
|
+
|
|
249
|
+
// Code for an update operation using update() //
|
|
250
|
+
|
|
251
|
+
function updateGreeting(itemId, language, greeting) {
|
|
252
|
+
const toUpdate = {
|
|
253
|
+
_id: itemId,
|
|
254
|
+
language,
|
|
255
|
+
greeting
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return items.update('Greetings', toUpdate);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Update an item in a collection with condition
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
import { items } from "@wix/data";
|
|
267
|
+
|
|
268
|
+
async function updateItem() {
|
|
269
|
+
const filter = items.filter().eq("active", true);
|
|
270
|
+
|
|
271
|
+
const toUpdate = {
|
|
272
|
+
"_id": "00001",
|
|
273
|
+
"title": "Mr.",
|
|
274
|
+
"first_name": "John",
|
|
275
|
+
"last_name": "Doe",
|
|
276
|
+
"active": true
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const updatedItem = await items.update("Users", toUpdate, { condition: filter });
|
|
280
|
+
console.log(updatedItem); // See below
|
|
281
|
+
}
|
|
282
|
+
/* item is:
|
|
283
|
+
*
|
|
284
|
+
* {
|
|
285
|
+
* "_id": "00001",
|
|
286
|
+
* "_owner": "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
|
|
287
|
+
* "_createdDate": "2017-05-24T12:33:18.938Z",
|
|
288
|
+
* "_updatedDate": "2017-05-24T12:33:18.938Z",
|
|
289
|
+
* "title": "Mr.",
|
|
290
|
+
* "first_name": "John",
|
|
291
|
+
* "last_name": "Doe",
|
|
292
|
+
* "active": true,
|
|
293
|
+
* }
|
|
294
|
+
*/
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## default
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
try {
|
|
301
|
+
const result = await items.update("collection-0.4576076907162254", {
|
|
302
|
+
"_id": "6892593d-d57f-428d-bc53-3f0870a1beef",
|
|
303
|
+
"_owner": "28962158-e9e0-4a9c-8bf0-5f654d78ccb6"
|
|
304
|
+
}, {
|
|
305
|
+
"appOptions": {},
|
|
306
|
+
"showDrafts": false,
|
|
307
|
+
"suppressHooks": false
|
|
308
|
+
});
|
|
309
|
+
return result;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.error(error);
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
</description>
|
|
42
316
|
<type_definition>
|
|
317
|
+
```
|
|
43
318
|
Method: data.items.update(dataCollectionId, item, options)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
319
|
+
Description: Updates an item in a collection. The `update()` method returns a Promise that resolves to the updated item from the specified collection. The Promise is rejected if the current user does not have update permissions for the collection. 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. The `update()` method compares the `_id` property of the specified item with the `_id` property values of the items in the specified collection. If an item in the collection has that `_id` value, `update()` replaces the item's property values with the ones in the specified item. If the existing item had properties with values and those properties were not included in the specified item, the values in those properties are lost. The item's `_updatedDate` property is also updated to the current date. Any valid JavaScript object can be used as a property value. The `update()` 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. When updating an item in a collection that has a reference field, set the value of the reference field to the referenced item's `_id` value or the entire referenced item object. The maximum size of an item that you can update in a collection is 500kb. > **Notes:** > - The specified item must include an `_id` property that already exists in the collection. > - The `update()` method does not support multi-reference fields. For multi-reference fields, use `replaceReferences()` or `insertReference()`. > - [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.
|
|
320
|
+
Method parameters:
|
|
321
|
+
param name: dataCollectionId | type: string | description: GUID of the collection item belongs to. | required: true
|
|
322
|
+
param name: item | type: WixDataItem | description: Data item to update. | required: true
|
|
323
|
+
- name: _id | type: string | description: Data item GUID.
|
|
324
|
+
- name: _owner | type: string | description: GUID of the user who created the item. Can be modified with site owner permissions.
|
|
325
|
+
param name: options | type: WixDataUpdateOptions | description: Options to use when processing this operation.
|
|
326
|
+
- name: appOptions | type: Record<string, any> | description: Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections).
|
|
327
|
+
- name: condition | type: WixDataFilter | description: If provided, item will be updated only if condition is met.
|
|
328
|
+
Method: data.items.and(filter)
|
|
329
|
+
Description: Adds an `and` condition to the filter. A filter with an `and` condition returns all items that meet the conditions defined on both sides of the condition. Use the `and()` method when performing compound queries. For example, the final filter in this set of queries returns results where status is either pending or rejected **and** age is either less than 25 or greater than 65. ```js let statusFilter = items.filter() .eq("status", "pending") .or(items.filter().eq("status", "rejected")); let ageFilter = items.filter() .lt("age", 25) .or(items.filter().gt("age", 65)); let statusAndAgeFilter = statusFilter.and(ageFilter); ``` > **Notes**: > - The `and()` method is designed to work with 2 or more queries or filters. If used with a single query or filter, it returns all items in a collection. > - When chaining multiple `WixDataFilter` methods to a filter, an `and` condition is implied. In such cases, you do not need to call the `and()` method explicitly. For example, this filter returns results where an item `status` is `active` and `age` is greater than 25: > ```js > items.filter().eq("status", "active").gt("age", 25); > ```
|
|
330
|
+
Method parameters:
|
|
331
|
+
param name: filter | type: WixDataFilter | description: `WixDataFilter` used with an `and` condition.
|
|
332
|
+
Return type: REFERENCE<WixDataFilter>
|
|
333
|
+
Method: data.items.between(field, rangeStart, rangeEnd)
|
|
334
|
+
Description: Refines a filter to match items where the value of the specified field is within the defined range. The `between()` method refines this filter to match items for which the value of the specified field is greater than or equal to `rangeStart` and less than `rangeEnd`. The method only compares values of [the same type](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type). The following types can be compared: - Number: Compared numerically. - Date: Compared as JavaScript Date objects. - String: Compared lexicographically: - `"A"` and `"M"` are considered between `"A"` and `"Z"`, but `"a"`, `"m"`, `"z"` and `"Z"` are not. - `"A"`, `"M"`, `"Z"`, and `"a"` are considered between `"A"` and `"z"`, but `"z"` is not. > **Note**: Items that do not have a value for the specified field are considered as the lowest comparable value and are ranked last.
|
|
335
|
+
Method parameters:
|
|
336
|
+
param name: field | type: string | description: Field to compare with `rangeStart` and `rangeEnd`.
|
|
337
|
+
param name: rangeStart | type: undefined | description: Starting value of the range to match.
|
|
338
|
+
param name: rangeEnd | type: undefined | description: Ending value of the range to match.
|
|
339
|
+
Return type: REFERENCE<WixDataFilter>
|
|
340
|
+
Method: data.items.contains(field, value)
|
|
341
|
+
Description: Refines a filter to match items where the value of the specified field contains the specified value. The `contains()` method refines the filter to only match items for which the value of the specified field contains the specified value. `contains()` is not case-sensitive, so the value `sunday` is considered to contain the value `Sun`. You can use `contains()` with a [field of type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data) is a string or a reference. When specifying a field of type reference, `contains()` matches by the GUID of the referenced item as a string. To compare by other data types, use the [`eq()`](https://dev.wix.com/docs/sdk/backend-modules/data/wix-data-items-sdk-1-0-0/wix-data-filter/eq) method.
|
|
342
|
+
Method parameters:
|
|
343
|
+
param name: field | type: string | description: Field whose value is compared with the provided value.
|
|
344
|
+
param name: value | type: string | description: Value to locate in the specified field.
|
|
345
|
+
Return type: REFERENCE<WixDataFilter>
|
|
346
|
+
Method: data.items.endsWith(field, value)
|
|
347
|
+
Description: Refines a filter to match items where the value of the specified field ends with a specified value. The `endsWith()` method refines this filter to only match items where the value of the specified field ends with the specified value. Matching with `endsWith()` is not case sensitive, so `"TEXT"` is considered to end with `"ext"`. You can only use `endsWith()` with a [field of type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data) string or reference. When specifying a field of type reference, `endsWith()` matches by the GUID of the referenced item as a string.
|
|
348
|
+
Method parameters:
|
|
349
|
+
param name: field | type: string | description: Field whose value is compared with the specified value.
|
|
350
|
+
param name: value | type: string | description: Value to look for at the end of the specified field value.
|
|
351
|
+
Return type: REFERENCE<WixDataFilter>
|
|
352
|
+
Method: data.items.eq(field, value)
|
|
353
|
+
Description: Refines a filter to match items where the value of the specified field equals the specified value. The `eq()` method refines this filter to only match items where the value of the specified field equals the specified `value`. Values of different [types](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data) are always considered not equal. For example, a number value stored as a string does not match the same number stored as a number. Matching strings with `eq()` is case sensitive, so `"text"` is not equal to `"Text"`. If `field` points to a collection field of type array, `eq()` includes the item as long as at least one array element matches the specified `value`.
|
|
354
|
+
Method parameters:
|
|
355
|
+
param name: field | type: string | description: Field whose value is compared with `value`.
|
|
356
|
+
param name: value | type: any | description: Value to compare with.
|
|
357
|
+
Return type: REFERENCE<WixDataFilter>
|
|
358
|
+
Method: data.items.ge(field, value)
|
|
359
|
+
Description: Refines a filter to match items where the value of the specified field is greater than or equal to the specified value. The `ge()` method refines this filter to only match items where the value of the specified field is greater than or equal to the specified value. The method only matches values of the same [data type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data). For example, a number value stored as a string does not match the same number stored as a number. If a field contains a number as a string, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest. The following field types can be compared: - Number: Compares numerically. - Date: Compares JavaScript Date objects. - String: Compares lexicographically, so `"abc"` is greater than or equal to `"ABC"` (because of the greater than), but `"ABC"` is not greater than or equal to `"abc"`. - Reference: Compares by the GUID of the referenced item as a string.
|
|
360
|
+
Method parameters:
|
|
361
|
+
param name: field | type: string | description: Field whose value is compared with the specified value.
|
|
362
|
+
param name: value | type: undefined | description: Value to match.
|
|
363
|
+
Return type: REFERENCE<WixDataFilter>
|
|
364
|
+
Method: data.items.gt(field, value)
|
|
365
|
+
Description: Refines a filter to match items where the value of the specified field is greater than the specified value. The `gt()` method refines this filter to only match items where the value of the specified field is greater than the specified value. The method only matches values of the same [data type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data). For example, a number value stored as a string does not match the same number stored as a number. If a field contains a number as a string, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest. The following field types can be compared: - Number: Compares numerically. - Date: Compares JavaScript Date objects. - String: Compares lexicographically, so `"text"` is greater than `"Text"`. - Reference: Compares by the GUID of the referenced item as a string.
|
|
366
|
+
Method parameters:
|
|
367
|
+
param name: field | type: string | description: Field whose value is compared with the specified value.
|
|
368
|
+
param name: value | type: undefined | description: Value to match.
|
|
369
|
+
Return type: REFERENCE<WixDataFilter>
|
|
370
|
+
Method: data.items.hasAll(field, values)
|
|
371
|
+
Description: Refines a filter to match items where the values of the specified field contain all of the specified values. The `hasAll()` method refines this filter to only match items where the specified field contains all of the specified values. Matching strings with `hasAll()` is case sensitive, so `"text"` is not equal to `"Text"`. If the value of the specified field is an array, `hasAll()` will match if there is a match in the elements of that array for all of the specified values. You can specify a list of values to match by providing an array of String, Number, or Date types as the `value` parameters.
|
|
372
|
+
Method parameters:
|
|
373
|
+
param name: field | type: string | description: Field whose value is compared with `values`.
|
|
374
|
+
param name: values | type: undefined | description: Values to match.
|
|
375
|
+
Return type: REFERENCE<WixDataFilter>
|
|
376
|
+
Method: data.items.hasSome(field, values)
|
|
377
|
+
Description: Refines a filter to match items where the values of the specified field contain any of the specified values. The `hasSome()` method refines this filter to only match items where the specified field contains any of the specified values. Matching strings with `hasSome()` is case sensitive, so `"text"` is not equal to `"Text"`. If the value of the specified field is an array, `hasSome()` will match if any of the elements of that array match any of the specified values. If the specified field contains multiple references, pass item GUIDs in the `value` field. In such a case, `hasSome()` will match if any of the multiple references match any of the specified GUID values. You can specify a list of values to match by providing an array of String, Number, or Date types as the `value` parameters.
|
|
378
|
+
Method parameters:
|
|
379
|
+
param name: field | type: string | description: Field whose value is compared with `value`.
|
|
380
|
+
param name: values | type: undefined | description: Values to match.
|
|
381
|
+
Return type: REFERENCE<WixDataFilter>
|
|
382
|
+
Method: data.items.isEmpty(field)
|
|
383
|
+
Description: Refines a filter to match items whose specified field does not exist or does not have any value. The `isEmpty()` method refines this filter to only match items where the value of the specified field is `null` or `undefined` or the field does not exist. If the field contains any value at all for a given item, including the empty string or an invalid value, that item will match the filter.
|
|
384
|
+
Method parameters:
|
|
385
|
+
param name: field | type: string | description: Field to check for a value.
|
|
386
|
+
Return type: REFERENCE<WixDataFilter>
|
|
387
|
+
Method: data.items.isNotEmpty(field)
|
|
388
|
+
Description: Refines a filter to match items whose specified field has any value. The `isNotEmpty()` method refines this filter to only match items where the value of the specified field is not `null` or `undefined`. If the field contains any value at all for a given item, including the empty string or an invalid value, that item will match the filter.
|
|
389
|
+
Method parameters:
|
|
390
|
+
param name: field | type: string | description: Field to check for a value.
|
|
391
|
+
Return type: REFERENCE<WixDataFilter>
|
|
392
|
+
Method: data.items.le(field, value)
|
|
393
|
+
Description: Refines a filter to match items where the value of the specified field is less than or equal to the specified value. The `le()` method refines this filter to only match items where the value of the specified field is less than or equal to the specified value. The method only matches values of the same [data type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data). For example, a number value stored as a string does not match the same number stored as a number. If a field contains a number as a string, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest. The following field types can be compared: - Number: Compares numerically. - Date: Compares JavaScript Date objects. - String: Compares lexicographically, so `"ABC"` is less than or equal to `"abc"` (because of the less than), but `"abc"` is not less than or equal to `"ABC"`. - Reference: Compares by the GUID of the referenced item as a string.
|
|
394
|
+
Method parameters:
|
|
395
|
+
param name: field | type: string | description: Field whose value is compared with the specified value.
|
|
396
|
+
param name: value | type: undefined | description: Value to match.
|
|
397
|
+
Return type: REFERENCE<WixDataFilter>
|
|
398
|
+
Method: data.items.lt(field, value)
|
|
399
|
+
Description: Refines a filter to match items where the value of the specified field is less than the specified value. The `lt()` method refines this filter to only match items where the value of the specified field is less than the specified `value`. The method only matches values of the same [data type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data). For example, a number value stored as a string does not match the same number stored as a number. If a field contains a number as a String, that value is compared alphabetically and not numerically. Items that do not have a value for the specified field are ranked lowest. The following field types can be compared: - Number: Compares numerically. - Date: Compares JavaScript Date objects. - String: Compares lexicographically, so `"Text"` is less than `"text"`. - Reference: Compares by the GUID of the referenced item as a String.
|
|
400
|
+
Method parameters:
|
|
401
|
+
param name: field | type: string | description: Field whose value is compared with `value`.
|
|
402
|
+
param name: value | type: undefined | description: Value to match.
|
|
403
|
+
Return type: REFERENCE<WixDataFilter>
|
|
404
|
+
Method: data.items.ne(field, value)
|
|
405
|
+
Description: Refines a filter to match items where the value of the specified field does not equal the specified value. The `ne()` method refines this filter to only match items where the value of the specified field does not equal the specified value. The method only matches values of the same [data type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data). For example, a number value stored as a string is considered not equal to the same number stored as a number. Matching strings with `ne()` is case sensitive, so `"text"` is considered not equal to `"Text"`. If the value of `field` is an array, `ne()` matches items where none of the elements of the array match the specified value.
|
|
406
|
+
Method parameters:
|
|
407
|
+
param name: field | type: string | description: Field whose value is compared with `value`.
|
|
408
|
+
param name: value | type: any | description: Value to match.
|
|
409
|
+
Return type: REFERENCE<WixDataFilter>
|
|
410
|
+
Method: data.items.not(filter)
|
|
411
|
+
Description: Adds a `not` condition to the filter. The `not()` method adds a `not` condition to this filter. A filter with a `not` returns all the items that match the filter as defined up to the `not` method, but don't match the filter passed to the `not` method. If the filter only contains a `not()` method, it returns all the items that don't match the filter defined by the `not` method.
|
|
412
|
+
Method parameters:
|
|
413
|
+
param name: filter | type: WixDataFilter | description: Filter to add to the initial filter as a `not` condition.
|
|
414
|
+
Return type: REFERENCE<WixDataFilter>
|
|
415
|
+
Method: data.items.or(filter)
|
|
416
|
+
Description: Adds an `or` condition to the filter. The `or()` method adds an inclusive `or` condition to this filter. A filter with an `or` returns all the items that match the filter as defined up to the `or` method, the items that match the filter passed to the `or` method, and the items that match both. The `or()` method is designed to work with 2 or more queries or filters. If you use it on its own, it will return all the items in a collection.
|
|
417
|
+
Method parameters:
|
|
418
|
+
param name: filter | type: WixDataFilter | description: Filter to add to the initial filter as an `or` condition.
|
|
419
|
+
Return type: REFERENCE<WixDataFilter>
|
|
420
|
+
Method: data.items.startsWith(field, value)
|
|
421
|
+
Description: Refines a filter to match items where the value of the specified field starts with a specified value. The `startsWith()` method refines this filter to only match items where the value of the specified field starts with the specified value. Matching with `startsWith()` is not case sensitive, so specifying `"TEXT"` is considered to start with `"tex"`. You can only use `startsWith()` with a [field of type](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-types-in-wix-data) string or reference. When specifying a field of type reference, `startsWith()` matches by the GUID of the referenced item as a string.
|
|
422
|
+
Method parameters:
|
|
423
|
+
param name: field | type: string | description: Field whose value is compared with the specified value.
|
|
424
|
+
param name: value | type: string | description: Value to look for at the beginning of the specified field value.
|
|
425
|
+
Return type: REFERENCE<WixDataFilter>
|
|
426
|
+
- name: showDrafts | type: boolean | description: When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. Default: `false`.
|
|
427
|
+
- name: suppressHooks | type: boolean | description: Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). Default: `false`.
|
|
428
|
+
Return type: PROMISE<WixDataItem>
|
|
429
|
+
- name: _createdDate | type: Date | description: Date and time the item was added to the collection.
|
|
430
|
+
- name: _id | type: string | description: Data item GUID.
|
|
431
|
+
- name: _owner | type: string | description: GUID of the user who created the item. Can be modified with site owner permissions.
|
|
432
|
+
- name: _updatedDate | type: Date | description: Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have the same value.
|
|
57
433
|
|
|
434
|
+
```
|
|
435
|
+
</type_definition>
|
|
436
|
+
</data_items_update>
|