@wix/agent-skills 1.0.0
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/LICENSE +21 -0
- package/README.md +111 -0
- package/package.json +29 -0
- package/skills/wix-app/SKILL.md +344 -0
- package/skills/wix-app/references/APP_IDENTIFIERS.md +35 -0
- package/skills/wix-app/references/APP_MARKET_REVIEW.md +311 -0
- package/skills/wix-app/references/APP_VALIDATION.md +171 -0
- package/skills/wix-app/references/BACKEND_API.md +233 -0
- package/skills/wix-app/references/BACKEND_EVENT.md +116 -0
- package/skills/wix-app/references/CODE_QUALITY.md +33 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +587 -0
- package/skills/wix-app/references/DASHBOARD_MENU_PLUGIN.md +157 -0
- package/skills/wix-app/references/DASHBOARD_MODAL.md +283 -0
- package/skills/wix-app/references/DASHBOARD_PAGE.md +403 -0
- package/skills/wix-app/references/DASHBOARD_PLUGIN.md +205 -0
- package/skills/wix-app/references/DATA_COLLECTION.md +451 -0
- package/skills/wix-app/references/DOCUMENTATION.md +42 -0
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +65 -0
- package/skills/wix-app/references/EMBEDDED_SCRIPT.md +468 -0
- package/skills/wix-app/references/EXTENSION_REGISTRATION.md +96 -0
- package/skills/wix-app/references/SERVICE_PLUGIN.md +235 -0
- package/skills/wix-app/references/SITE_PLUGIN.md +436 -0
- package/skills/wix-app/references/STORES_VERSIONING.md +334 -0
- package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +84 -0
- package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +345 -0
- package/skills/wix-app/references/dashboard-menu-plugin/blog-slots.md +71 -0
- package/skills/wix-app/references/dashboard-menu-plugin/bookings-slots.md +58 -0
- package/skills/wix-app/references/dashboard-menu-plugin/crm-slots.md +8 -0
- package/skills/wix-app/references/dashboard-menu-plugin/ecommerce-slots.md +17 -0
- package/skills/wix-app/references/dashboard-menu-plugin/events-slots.md +29 -0
- package/skills/wix-app/references/dashboard-menu-plugin/restaurants-slots.md +27 -0
- package/skills/wix-app/references/dashboard-menu-plugin/stores-slots.md +35 -0
- package/skills/wix-app/references/dashboard-page/API_SPEC.md +138 -0
- package/skills/wix-app/references/dashboard-page/DASHBOARD_API.md +573 -0
- package/skills/wix-app/references/dashboard-page/DYNAMIC_PARAMETERS.md +269 -0
- package/skills/wix-app/references/dashboard-page/ECOM_NAVIGATION.md +164 -0
- package/skills/wix-app/references/dashboard-plugin/SLOTS.md +294 -0
- package/skills/wix-app/references/data-collection/WIX_DATA.md +270 -0
- package/skills/wix-app/references/data-collection/extension-template.ts +107 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +138 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +454 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +165 -0
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +576 -0
- package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +170 -0
- package/skills/wix-app/references/editor-react-component/EDIT-FLOW.md +6 -0
- package/skills/wix-app/references/editor-react-component/PARTS.md +25 -0
- package/skills/wix-app/references/editor-react-component/PROPS-VS-CSS.md +203 -0
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +167 -0
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +137 -0
- package/skills/wix-app/references/service-plugin/ADDITIONAL-FEES.md +112 -0
- package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +118 -0
- package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +87 -0
- package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +86 -0
- package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +135 -0
- package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +79 -0
- package/skills/wix-app/references/service-plugin/VALIDATIONS.md +68 -0
- package/skills/wix-app/references/site-plugin/EXAMPLES.md +311 -0
- package/skills/wix-app/references/site-plugin/SLOTS.md +263 -0
- package/skills/wix-design-system/SKILL.md +129 -0
- package/skills/wix-design-system/references/file-structure.md +56 -0
- package/skills/wix-design-system/scripts/wds.cjs +531 -0
- package/skills/wix-headless/SKILL.md +418 -0
- package/skills/wix-headless/references/DISCOVERY.md +332 -0
- package/skills/wix-headless/references/ORCHESTRATION.md +269 -0
- package/skills/wix-headless/references/SETUP.md +154 -0
- package/skills/wix-headless/references/blog/BLOG_CONTENT.md +152 -0
- package/skills/wix-headless/references/blog/BLOG_PAGES.md +299 -0
- package/skills/wix-headless/references/blog/BLOG_SETUP.md +218 -0
- package/skills/wix-headless/references/blog/INSTRUCTIONS.md +32 -0
- package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +373 -0
- package/skills/wix-headless/references/cms/FAQ_KNOWLEDGE_BASE.md +229 -0
- package/skills/wix-headless/references/cms/INSTRUCTIONS.md +40 -0
- package/skills/wix-headless/references/cms/PORTFOLIO.md +454 -0
- package/skills/wix-headless/references/cms/RESOURCE_LIBRARY.md +356 -0
- package/skills/wix-headless/references/cms/TEAM_DIRECTORY.md +299 -0
- package/skills/wix-headless/references/commands/install-app.md +42 -0
- package/skills/wix-headless/references/commands/known-apps.json +5 -0
- package/skills/wix-headless/references/commands/mcp-bootstrap.md +28 -0
- package/skills/wix-headless/references/designer/INSTRUCTIONS.md +828 -0
- package/skills/wix-headless/references/ecom/CART_PAGES.md +120 -0
- package/skills/wix-headless/references/ecom/CART_WIRING.md +103 -0
- package/skills/wix-headless/references/ecom/COMPONENTS_CSS.md +132 -0
- package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +59 -0
- package/skills/wix-headless/references/forms/CONTACT_FORM.md +477 -0
- package/skills/wix-headless/references/forms/INSTRUCTIONS.md +43 -0
- package/skills/wix-headless/references/gift-cards/COMPONENTS.md +119 -0
- package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +51 -0
- package/skills/wix-headless/references/gift-cards/PAGES.md +129 -0
- package/skills/wix-headless/references/images/INSTRUCTIONS.md +359 -0
- package/skills/wix-headless/references/shared/BUILD_NOISE.md +8 -0
- package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +185 -0
- package/skills/wix-headless/references/shared/IMPLEMENTER.md +155 -0
- package/skills/wix-headless/references/shared/MCP_PREFIX.md +105 -0
- package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +97 -0
- package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +423 -0
- package/skills/wix-headless/references/shared/STYLING.md +117 -0
- package/skills/wix-headless/references/stores/BACK_IN_STOCK.md +178 -0
- package/skills/wix-headless/references/stores/CATEGORY_PAGES.md +86 -0
- package/skills/wix-headless/references/stores/COMPONENTS_CSS.md +129 -0
- package/skills/wix-headless/references/stores/HOME_AND_NAV.md +227 -0
- package/skills/wix-headless/references/stores/INSTRUCTIONS.md +96 -0
- package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +249 -0
- package/skills/wix-headless/references/stores/PRODUCT_PAGES.md +213 -0
- package/skills/wix-headless/references/stores/SHARED_WIRING.md +164 -0
- package/skills/wix-headless/references/verticals/_schema.json +160 -0
- package/skills/wix-headless/references/verticals/_schema.md +185 -0
- package/skills/wix-headless/references/verticals/blog.md +125 -0
- package/skills/wix-headless/references/verticals/cms.md +121 -0
- package/skills/wix-headless/references/verticals/ecom.md +96 -0
- package/skills/wix-headless/references/verticals/forms.md +106 -0
- package/skills/wix-headless/references/verticals/gift-cards.md +121 -0
- package/skills/wix-headless/references/verticals/stores.md +167 -0
- package/skills/wix-headless/scripts/check-manifest.mjs +198 -0
- package/skills/wix-headless/scripts/copy-utility-templates.mjs +153 -0
- package/skills/wix-headless/scripts/emit-design-tokens.mjs +77 -0
- package/skills/wix-headless/scripts/finalize-run-json.mjs +141 -0
- package/skills/wix-headless/scripts/init-site-json.mjs +63 -0
- package/skills/wix-headless/scripts/patch-decorative-slots.mjs +124 -0
- package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +190 -0
- package/skills/wix-headless/scripts/preview.sh +45 -0
- package/skills/wix-headless/scripts/release.sh +73 -0
- package/skills/wix-headless/scripts/scaffold.sh +53 -0
- package/skills/wix-headless/scripts/seed-utilities.sh +55 -0
- package/skills/wix-headless/shared-utilities/analytics.ts +40 -0
- package/skills/wix-headless/shared-utilities/ricos.ts +179 -0
- package/skills/wix-headless/shared-utilities/wix-image.ts +72 -0
- package/skills/wix-headless/templates/ecom/CartBadge.tsx +84 -0
- package/skills/wix-headless/templates/ecom/CartView.tsx +543 -0
- package/skills/wix-headless/templates/ecom/cart.astro +13 -0
- package/skills/wix-headless/templates/ecom/components-ecom.css +215 -0
- package/skills/wix-headless/templates/ecom/discounts.ts +71 -0
- package/skills/wix-headless/templates/ecom/thank-you.astro +24 -0
- package/skills/wix-headless/templates/gift-cards/GiftCardPurchase.tsx +172 -0
- package/skills/wix-headless/templates/gift-cards/_home-teaser-snippet.astro +42 -0
- package/skills/wix-headless/templates/gift-cards/_nav-snippet.astro +11 -0
- package/skills/wix-headless/templates/gift-cards/components-gift-cards.css +219 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.astro +51 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.ts +75 -0
- package/skills/wix-headless/templates/stores/AddToCartButton.tsx +77 -0
- package/skills/wix-headless/templates/stores/BackInStockForm.tsx +176 -0
- package/skills/wix-headless/templates/stores/CategoryRail.astro +69 -0
- package/skills/wix-headless/templates/stores/ProductCard.astro +79 -0
- package/skills/wix-headless/templates/stores/ProductPurchase.tsx +397 -0
- package/skills/wix-headless/templates/stores/SeoTags.astro +21 -0
- package/skills/wix-headless/templates/stores/back-in-stock.ts +67 -0
- package/skills/wix-headless/templates/stores/categories.ts +155 -0
- package/skills/wix-headless/templates/stores/category/[slug].astro +130 -0
- package/skills/wix-headless/templates/stores/components-stores.css +295 -0
- package/skills/wix-headless/templates/stores/products/[slug].astro +128 -0
- package/skills/wix-headless/templates/stores/products/index.astro +101 -0
- package/skills/wix-manage/SKILL.md +280 -0
- package/skills/wix-manage/references/app-installation/install-wix-apps.md +155 -0
- package/skills/wix-manage/references/app-installation/list-installed-apps.md +124 -0
- package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +226 -0
- package/skills/wix-manage/references/bookings/booking-service-policy-setup.md +95 -0
- package/skills/wix-manage/references/bookings/booking-system-integration-gaps.md +416 -0
- package/skills/wix-manage/references/bookings/bookings-staff-setup.md +255 -0
- package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +462 -0
- package/skills/wix-manage/references/bookings/end-to-end-booking-flow.md +278 -0
- package/skills/wix-manage/references/bookings/external-calendar-integration.md +258 -0
- package/skills/wix-manage/references/bookings/multi-resource-service-creation.md +231 -0
- package/skills/wix-manage/references/calendar/configure-default-business-hours.md +226 -0
- package/skills/wix-manage/references/cms/cms-data-items-crud.md +422 -0
- package/skills/wix-manage/references/cms/cms-data-operations-extended.md +263 -0
- package/skills/wix-manage/references/cms/cms-ecommerce-catalog-integration.md +136 -0
- package/skills/wix-manage/references/cms/cms-references-and-relationships.md +160 -0
- package/skills/wix-manage/references/cms/cms-schema-management.md +143 -0
- package/skills/wix-manage/references/contacts/bulk-delete-contacts.md +73 -0
- package/skills/wix-manage/references/contacts/bulk-label-and-unlabel-contacts.md +67 -0
- package/skills/wix-manage/references/domains/domain-search-and-purchase.md +434 -0
- package/skills/wix-manage/references/ecommerce/api-recommendation-tracking.md +420 -0
- package/skills/wix-manage/references/ecommerce/flow-add-free-shipping.md +267 -0
- package/skills/wix-manage/references/ecommerce/flow-bundle-and-save.md +290 -0
- package/skills/wix-manage/references/ecommerce/flow-fix-coverage-gaps.md +300 -0
- package/skills/wix-manage/references/ecommerce/flow-optimize-shipping-rates.md +364 -0
- package/skills/wix-manage/references/ecommerce/flow-seasonal-promotion.md +315 -0
- package/skills/wix-manage/references/ecommerce/flow-stock-mover.md +308 -0
- package/skills/wix-manage/references/ecommerce/flow-upsell-boost.md +271 -0
- package/skills/wix-manage/references/ecommerce/goal-clear-inventory.md +118 -0
- package/skills/wix-manage/references/ecommerce/goal-drive-cross-sells.md +122 -0
- package/skills/wix-manage/references/ecommerce/goal-increase-aov.md +132 -0
- package/skills/wix-manage/references/ecommerce/goal-reduce-cart-abandonment.md +148 -0
- package/skills/wix-manage/references/ecommerce/goal-seasonal-revenue.md +146 -0
- package/skills/wix-manage/references/ecommerce/guardrail-discount-conflicts.md +118 -0
- package/skills/wix-manage/references/ecommerce/guardrail-margin-protection.md +88 -0
- package/skills/wix-manage/references/ecommerce/guardrail-rate-pricing-sanity.md +108 -0
- package/skills/wix-manage/references/ecommerce/guardrail-shipping-health.md +124 -0
- package/skills/wix-manage/references/ecommerce/recipe-apply-shipping-recommendations.md +299 -0
- package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +582 -0
- package/skills/wix-manage/references/ecommerce/setup-coupons.md +338 -0
- package/skills/wix-manage/references/ecommerce/setup-discount-rules.md +444 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-rates.md +86 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-regions.md +56 -0
- package/skills/wix-manage/references/ecommerce/setup-store-pickup-location.md +209 -0
- package/skills/wix-manage/references/ecommerce/skill-graph.md +139 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-checkout-delivery-dropoff.md +124 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-discount-not-applying.md +95 -0
- package/skills/wix-manage/references/events/list-events.md +203 -0
- package/skills/wix-manage/references/forms/create-form.md +260 -0
- package/skills/wix-manage/references/get-paid/create-payment-links.md +212 -0
- package/skills/wix-manage/references/get-paid/how-to-setup-wix-payments.md +57 -0
- package/skills/wix-manage/references/get-paid/payment-links-for-bookings.md +101 -0
- package/skills/wix-manage/references/media/upload-media-to-wix.md +216 -0
- package/skills/wix-manage/references/pricing-plans/create-and-update-pricing-plans.md +77 -0
- package/skills/wix-manage/references/pricing-plans/pricing-plans-bookings-integration.md +166 -0
- package/skills/wix-manage/references/restaurants/wix-restaurants-setup.md +336 -0
- package/skills/wix-manage/references/rich-content/ricos-converter-service.md +295 -0
- package/skills/wix-manage/references/site-properties/change-payment-currency-site-properties.md +59 -0
- package/skills/wix-manage/references/sites/create-site-from-template.md +183 -0
- package/skills/wix-manage/references/sites/query-sites.md +125 -0
- package/skills/wix-manage/references/stores/add-store-pages-to-site.md +57 -0
- package/skills/wix-manage/references/stores/bulk-create-products-with-options.md +1041 -0
- package/skills/wix-manage/references/stores/create-product-catalog-v1.md +125 -0
- package/skills/wix-manage/references/stores/create-product-from-image.md +824 -0
- package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +566 -0
- package/skills/wix-manage/references/stores/find-products-query-and-search-catalog-v3.md +194 -0
- package/skills/wix-manage/references/stores/query-products-catalog-v1.md +80 -0
- package/skills/wix-manage/references/stores/setup-online-store-catalog-v3.md +99 -0
- package/skills/wix-manage/references/stores/update-product-pre-order.md +213 -0
- package/skills/wix-manage/references/stores/update-product-with-options.md +318 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "CMS Data Items CRUD"
|
|
3
|
+
description: "Add, query, update, and delete items in CMS collections. Use this to insert content, bulk insert/update/patch/delete items, query with filters, and manage collection data. Key endpoints: /wix-data/v2/items, /wix-data/v2/bulk/items/*."
|
|
4
|
+
---
|
|
5
|
+
# CMS Data Items CRUD
|
|
6
|
+
|
|
7
|
+
This recipe covers basic Create, Read, Update, Delete (CRUD) operations for Wix CMS data items.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
1. Wix CMS enabled on the site
|
|
12
|
+
2. Collections already created (see [CMS Schema Management](cms-schema-management.md))
|
|
13
|
+
3. API access with CMS permissions
|
|
14
|
+
|
|
15
|
+
## Required APIs
|
|
16
|
+
|
|
17
|
+
- **Data Items API**: [REST](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Know the Schema First
|
|
22
|
+
|
|
23
|
+
Before inserting or updating items, you need to know the collection's field names and types. If you don't already know the schema:
|
|
24
|
+
|
|
25
|
+
1. **Query existing items** - Fetch a few items to infer field names from the data
|
|
26
|
+
2. **Get collection schema** - Use `GET /collections/{collectionId}` for full field definitions
|
|
27
|
+
3. **List collections** - Use `GET /collections?fields=id` to see what collections exist (see [Schema Management](cms-schema-management.md))
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Insert Data Item
|
|
32
|
+
|
|
33
|
+
**Endpoint**: `POST /wix-data/v2/items`
|
|
34
|
+
|
|
35
|
+
**Request Body**:
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"dataCollectionId": "Products",
|
|
39
|
+
"dataItem": {
|
|
40
|
+
"data": {
|
|
41
|
+
"title": "Wireless Headphones",
|
|
42
|
+
"price": 149.99,
|
|
43
|
+
"description": "Premium wireless headphones with noise cancellation",
|
|
44
|
+
"inStock": true,
|
|
45
|
+
"tags": ["wireless", "audio", "premium"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Response**:
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"dataItem": {
|
|
55
|
+
"id": "generated-item-id",
|
|
56
|
+
"dataCollectionId": "Products",
|
|
57
|
+
"data": {
|
|
58
|
+
"_id": "generated-item-id",
|
|
59
|
+
"title": "Wireless Headphones",
|
|
60
|
+
"price": 149.99,
|
|
61
|
+
"_createdDate": { "$date": "2024-01-15T10:00:00.000Z" },
|
|
62
|
+
"_updatedDate": { "$date": "2024-01-15T10:00:00.000Z" }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Bulk Insert Items
|
|
69
|
+
|
|
70
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/insert`
|
|
71
|
+
|
|
72
|
+
**Request Body**:
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"dataCollectionId": "Products",
|
|
76
|
+
"dataItems": [
|
|
77
|
+
{
|
|
78
|
+
"data": {
|
|
79
|
+
"title": "Bluetooth Speaker",
|
|
80
|
+
"price": 79.99,
|
|
81
|
+
"inStock": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"data": {
|
|
86
|
+
"title": "USB-C Cable",
|
|
87
|
+
"price": 12.99,
|
|
88
|
+
"inStock": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"data": {
|
|
93
|
+
"title": "Laptop Stand",
|
|
94
|
+
"price": 49.99,
|
|
95
|
+
"inStock": false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"returnEntity": true
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Query Data Items
|
|
104
|
+
|
|
105
|
+
**Endpoint**: `POST /wix-data/v2/items/query`
|
|
106
|
+
|
|
107
|
+
**Basic Query**:
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"dataCollectionId": "Products",
|
|
111
|
+
"query": {
|
|
112
|
+
"filter": {
|
|
113
|
+
"inStock": true
|
|
114
|
+
},
|
|
115
|
+
"sort": [
|
|
116
|
+
{
|
|
117
|
+
"fieldName": "price",
|
|
118
|
+
"order": "ASC"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"paging": {
|
|
122
|
+
"limit": 50,
|
|
123
|
+
"offset": 0
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Advanced Query with Multiple Conditions**:
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"dataCollectionId": "Products",
|
|
133
|
+
"query": {
|
|
134
|
+
"filter": {
|
|
135
|
+
"$and": [
|
|
136
|
+
{ "inStock": true },
|
|
137
|
+
{ "price": { "$gte": 50, "$lte": 200 } }
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Text Search**:
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"dataCollectionId": "Products",
|
|
148
|
+
"query": {
|
|
149
|
+
"filter": {
|
|
150
|
+
"title": {
|
|
151
|
+
"$contains": "wireless"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Get Single Item
|
|
159
|
+
|
|
160
|
+
**Endpoint**: `GET /wix-data/v2/items/{itemId}?dataCollectionId={collectionId}`
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
curl -X GET \
|
|
164
|
+
'https://www.wixapis.com/wix-data/v2/items/abc123?dataCollectionId=Products' \
|
|
165
|
+
-H 'Authorization: <AUTH>'
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Update Data Item
|
|
169
|
+
|
|
170
|
+
**Endpoint**: `PUT /wix-data/v2/items/{itemId}`
|
|
171
|
+
|
|
172
|
+
**Request Body**:
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"dataCollectionId": "Products",
|
|
176
|
+
"dataItem": {
|
|
177
|
+
"data": {
|
|
178
|
+
"title": "Wireless Headphones Pro",
|
|
179
|
+
"price": 199.99,
|
|
180
|
+
"description": "Updated premium wireless headphones",
|
|
181
|
+
"inStock": true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Patch Data Item (Partial Update - Single Item)
|
|
188
|
+
|
|
189
|
+
**Endpoint**: `PATCH /wix-data/v2/items/{dataItemId}`
|
|
190
|
+
|
|
191
|
+
Unlike Update, this only modifies the specified fields — all other fields remain unchanged.
|
|
192
|
+
|
|
193
|
+
> **Note**: Only works on user-created collections. Wix app collections (e.g. Wix Stores Products) cannot be patched.
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"dataCollectionId": "Products",
|
|
198
|
+
"patch": {
|
|
199
|
+
"dataItemId": "item-guid",
|
|
200
|
+
"fieldModifications": [
|
|
201
|
+
{
|
|
202
|
+
"fieldPath": "price",
|
|
203
|
+
"action": "SET_FIELD",
|
|
204
|
+
"setFieldOptions": {
|
|
205
|
+
"value": 159.99
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"fieldPath": "description",
|
|
210
|
+
"action": "REMOVE_FIELD"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"fieldPath": "viewCount",
|
|
214
|
+
"action": "INCREMENT_FIELD",
|
|
215
|
+
"incrementFieldOptions": {
|
|
216
|
+
"value": 1
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Bulk Update Items
|
|
225
|
+
|
|
226
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/update`
|
|
227
|
+
|
|
228
|
+
> **Important**: Use `id` (not `_id`) at the element level. The `data` object should NOT contain `_id`.
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"dataCollectionId": "Products",
|
|
233
|
+
"dataItems": [
|
|
234
|
+
{
|
|
235
|
+
"id": "item-guid-1",
|
|
236
|
+
"data": {
|
|
237
|
+
"price": 159.99,
|
|
238
|
+
"inStock": true
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"id": "item-guid-2",
|
|
243
|
+
"data": {
|
|
244
|
+
"price": 89.99,
|
|
245
|
+
"inStock": false
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
> **Note**: This replaces the entire item. Include all fields you want to keep, not just the ones you're changing.
|
|
253
|
+
|
|
254
|
+
## Bulk Patch Items (Partial Update)
|
|
255
|
+
|
|
256
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/patch`
|
|
257
|
+
|
|
258
|
+
Unlike bulk update, this only modifies the specified fields - other fields remain unchanged. **Use this for partial updates.**
|
|
259
|
+
|
|
260
|
+
> **Important**: This endpoint uses `patches` array with `fieldModifications`, NOT `dataItems`. Do not confuse with bulk update.
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"dataCollectionId": "Products",
|
|
265
|
+
"patches": [
|
|
266
|
+
{
|
|
267
|
+
"dataItemId": "item-guid-1",
|
|
268
|
+
"fieldModifications": [
|
|
269
|
+
{
|
|
270
|
+
"fieldPath": "price",
|
|
271
|
+
"action": "SET_FIELD",
|
|
272
|
+
"setFieldOptions": {
|
|
273
|
+
"value": 159.99
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"dataItemId": "item-guid-2",
|
|
280
|
+
"fieldModifications": [
|
|
281
|
+
{
|
|
282
|
+
"fieldPath": "price",
|
|
283
|
+
"action": "SET_FIELD",
|
|
284
|
+
"setFieldOptions": {
|
|
285
|
+
"value": 89.99
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Setting a reference field** (single REFERENCE only):
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"dataCollectionId": "events",
|
|
298
|
+
"patches": [
|
|
299
|
+
{
|
|
300
|
+
"dataItemId": "event-id",
|
|
301
|
+
"fieldModifications": [
|
|
302
|
+
{
|
|
303
|
+
"fieldPath": "venue",
|
|
304
|
+
"action": "SET_FIELD",
|
|
305
|
+
"setFieldOptions": {
|
|
306
|
+
"value": "venue-item-id"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Available actions**: `SET_FIELD`, `REMOVE_FIELD`, `INCREMENT_FIELD`, `APPEND_TO_ARRAY`, `REMOVE_FROM_ARRAY`
|
|
316
|
+
|
|
317
|
+
> **Common error**: If you get `WDE0080: patches must not be empty`, you sent `dataItems` instead of `patches`. Use the format above.
|
|
318
|
+
|
|
319
|
+
> **Recommended**: Use bulk patch instead of bulk update when you only need to change specific fields.
|
|
320
|
+
|
|
321
|
+
> **Reference Fields**:
|
|
322
|
+
> - **Single REFERENCE**: CAN be set during insert/update by providing the referenced item's ID as the field value (e.g., `"venue": "venue-item-id"`)
|
|
323
|
+
> - **MULTI_REFERENCE**: **STOP** - You cannot use this recipe for multi-reference fields. They cannot be set via insert/update/patch.
|
|
324
|
+
>
|
|
325
|
+
> **For MULTI_REFERENCE operations (add speakers, assign tags, link categories, etc.):**
|
|
326
|
+
> **READ [CMS References & Relationships](cms-references-and-relationships.md)** for the exact endpoints and request bodies:
|
|
327
|
+
> - `POST /wix-data/v2/bulk/items/insert-references` - add references
|
|
328
|
+
> - `POST /wix-data/v2/items/replace-references` - replace all references
|
|
329
|
+
> - `POST /wix-data/v2/bulk/items/remove-references` - remove references
|
|
330
|
+
>
|
|
331
|
+
> Error `WDE0303` occurs when attempting to set multi-reference fields via data operations.
|
|
332
|
+
|
|
333
|
+
## Delete Data Item
|
|
334
|
+
|
|
335
|
+
**Endpoint**: `DELETE /wix-data/v2/items/{itemId}?dataCollectionId={collectionId}`
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
curl -X DELETE \
|
|
339
|
+
'https://www.wixapis.com/wix-data/v2/items/abc123?dataCollectionId=Products' \
|
|
340
|
+
-H 'Authorization: <AUTH>'
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Bulk Delete Items
|
|
344
|
+
|
|
345
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/remove`
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"dataCollectionId": "Products",
|
|
350
|
+
"dataItemIds": ["item-id-1", "item-id-2", "item-id-3"]
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Query Operators
|
|
357
|
+
|
|
358
|
+
| Operator | Description | Example |
|
|
359
|
+
|----------|-------------|---------|
|
|
360
|
+
| `$eq` | Equal | `{ "status": { "$eq": "active" } }` |
|
|
361
|
+
| `$ne` | Not equal | `{ "status": { "$ne": "archived" } }` |
|
|
362
|
+
| `$gt` | Greater than | `{ "price": { "$gt": 100 } }` |
|
|
363
|
+
| `$gte` | Greater or equal | `{ "price": { "$gte": 100 } }` |
|
|
364
|
+
| `$lt` | Less than | `{ "price": { "$lt": 50 } }` |
|
|
365
|
+
| `$lte` | Less or equal | `{ "price": { "$lte": 50 } }` |
|
|
366
|
+
| `$in` | In array | `{ "status": { "$in": ["active", "pending"] } }` |
|
|
367
|
+
| `$contains` | Contains string | `{ "title": { "$contains": "pro" } }` |
|
|
368
|
+
| `$startsWith` | Starts with | `{ "title": { "$startsWith": "Wireless" } }` |
|
|
369
|
+
| `$and` | All conditions | `{ "$and": [{...}, {...}] }` |
|
|
370
|
+
| `$or` | Any condition | `{ "$or": [{...}, {...}] }` |
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Pagination
|
|
375
|
+
|
|
376
|
+
### Offset-Based (Simple)
|
|
377
|
+
```json
|
|
378
|
+
{
|
|
379
|
+
"query": {
|
|
380
|
+
"paging": {
|
|
381
|
+
"limit": 50,
|
|
382
|
+
"offset": 100
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Cursor-Based (Large Datasets)
|
|
389
|
+
```json
|
|
390
|
+
{
|
|
391
|
+
"query": {
|
|
392
|
+
"cursorPaging": {
|
|
393
|
+
"limit": 50,
|
|
394
|
+
"cursor": "cursor-from-previous-response"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Error Handling
|
|
403
|
+
|
|
404
|
+
| Error | Cause | Solution |
|
|
405
|
+
|-------|-------|----------|
|
|
406
|
+
| `COLLECTION_NOT_FOUND` | Invalid collection ID | Check collection exists |
|
|
407
|
+
| `ITEM_NOT_FOUND` | Invalid item ID | Verify item exists |
|
|
408
|
+
| `VALIDATION_ERROR` | Invalid field value | Check field types |
|
|
409
|
+
| `DUPLICATE_KEY` | Duplicate unique field | Use unique values |
|
|
410
|
+
| `PERMISSION_DENIED` | Insufficient access | Check API permissions |
|
|
411
|
+
| `WDE0007` | Bulk update: wrong ID field name | Use `id` not `_id` at element level |
|
|
412
|
+
| `WDE0080` | Validation failed (multiple causes) | Bulk update: don't include `_id` in `data`; Bulk patch: use `patches` array not `dataItems` |
|
|
413
|
+
| `WDE0303` | Can't set multi-reference field via data operations | Use reference endpoints: `insert-references`, `replace-references` |
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Related Documentation
|
|
418
|
+
|
|
419
|
+
- [Data Items API Reference](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction)
|
|
420
|
+
- [CMS Schema Management](cms-schema-management.md) - Creating and modifying collections
|
|
421
|
+
- [CMS References & Relationships](cms-references-and-relationships.md) - Linking collections
|
|
422
|
+
- [CMS Data Operations Extended](cms-data-operations-extended.md) - Count, upsert, aggregate
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "CMS Data Operations Extended"
|
|
3
|
+
description: Additional CMS data operations including count, upsert (bulk save), and update by filter patterns.
|
|
4
|
+
---
|
|
5
|
+
# CMS Data Operations Extended
|
|
6
|
+
|
|
7
|
+
This recipe covers additional CMS data operations not included in the basic CRUD recipe.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
1. Wix CMS enabled on the site
|
|
12
|
+
2. Collections created with data
|
|
13
|
+
3. API access with CMS permissions
|
|
14
|
+
|
|
15
|
+
## Required APIs
|
|
16
|
+
|
|
17
|
+
- **Data Items API**: [REST](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction)
|
|
18
|
+
|
|
19
|
+
## Count Data Items
|
|
20
|
+
|
|
21
|
+
Count items in a collection, optionally with filters.
|
|
22
|
+
|
|
23
|
+
**Endpoint**: `POST /wix-data/v2/items/count`
|
|
24
|
+
|
|
25
|
+
**Count All Items**:
|
|
26
|
+
```bash
|
|
27
|
+
curl -X POST \
|
|
28
|
+
'https://www.wixapis.com/wix-data/v2/items/count' \
|
|
29
|
+
-H 'Content-Type: application/json' \
|
|
30
|
+
-H 'Authorization: <AUTH>' \
|
|
31
|
+
-d '{
|
|
32
|
+
"dataCollectionId": "Products"
|
|
33
|
+
}'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Response**:
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"totalCount": 42
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Count with Filter**:
|
|
44
|
+
```bash
|
|
45
|
+
curl -X POST \
|
|
46
|
+
'https://www.wixapis.com/wix-data/v2/items/count' \
|
|
47
|
+
-H 'Content-Type: application/json' \
|
|
48
|
+
-H 'Authorization: <AUTH>' \
|
|
49
|
+
-d '{
|
|
50
|
+
"dataCollectionId": "Products",
|
|
51
|
+
"filter": {
|
|
52
|
+
"inStock": true
|
|
53
|
+
}
|
|
54
|
+
}'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Count with Complex Filter**:
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"dataCollectionId": "Products",
|
|
61
|
+
"filter": {
|
|
62
|
+
"$and": [
|
|
63
|
+
{ "inStock": true },
|
|
64
|
+
{ "price": { "$gte": 50 } }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Bulk Save (Upsert)
|
|
71
|
+
|
|
72
|
+
Insert new items or update existing items in a single operation. This is useful for syncing data.
|
|
73
|
+
|
|
74
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/save`
|
|
75
|
+
|
|
76
|
+
**Request Body**:
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"dataCollectionId": "Products",
|
|
80
|
+
"dataItems": [
|
|
81
|
+
{
|
|
82
|
+
"id": "existing-item-id",
|
|
83
|
+
"data": {
|
|
84
|
+
"title": "Updated Product",
|
|
85
|
+
"price": 199.99,
|
|
86
|
+
"inStock": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"data": {
|
|
91
|
+
"title": "New Product",
|
|
92
|
+
"price": 79.99,
|
|
93
|
+
"inStock": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"returnEntity": true
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Bulk Save Behavior
|
|
102
|
+
|
|
103
|
+
| Scenario | Action |
|
|
104
|
+
|----------|--------|
|
|
105
|
+
| No `id` provided | INSERT - Creates new item with generated ID |
|
|
106
|
+
| `id` provided, doesn't exist | INSERT - Creates new item with provided ID |
|
|
107
|
+
| `id` provided, exists | UPDATE - Replaces existing item |
|
|
108
|
+
|
|
109
|
+
> **Warning**: When updating, the entire item is replaced. Include all fields you want to keep.
|
|
110
|
+
|
|
111
|
+
## Update by Filter Pattern
|
|
112
|
+
|
|
113
|
+
Wix CMS doesn't have a direct "update by filter" API. Use this two-step pattern:
|
|
114
|
+
|
|
115
|
+
### 3.1: Query Items to Update
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
curl -X POST \
|
|
119
|
+
'https://www.wixapis.com/wix-data/v2/items/query' \
|
|
120
|
+
-H 'Content-Type: application/json' \
|
|
121
|
+
-H 'Authorization: <AUTH>' \
|
|
122
|
+
-d '{
|
|
123
|
+
"dataCollectionId": "Products",
|
|
124
|
+
"query": {
|
|
125
|
+
"filter": {
|
|
126
|
+
"category": "electronics"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 3.2: Bulk Update Those Items
|
|
133
|
+
|
|
134
|
+
> **Important**: Use `id` (not `_id`) at the element level. The `data` object should NOT contain `_id`.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
curl -X POST \
|
|
138
|
+
'https://www.wixapis.com/wix-data/v2/bulk/items/update' \
|
|
139
|
+
-H 'Content-Type: application/json' \
|
|
140
|
+
-H 'Authorization: <AUTH>' \
|
|
141
|
+
-d '{
|
|
142
|
+
"dataCollectionId": "Products",
|
|
143
|
+
"dataItems": [
|
|
144
|
+
{
|
|
145
|
+
"id": "item-1-from-query",
|
|
146
|
+
"data": {
|
|
147
|
+
"title": "Updated Title 1",
|
|
148
|
+
"price": 99.99,
|
|
149
|
+
"onSale": true
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "item-2-from-query",
|
|
154
|
+
"data": {
|
|
155
|
+
"title": "Updated Title 2",
|
|
156
|
+
"price": 149.99,
|
|
157
|
+
"onSale": true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Alternative: Bulk Patch (Partial Update)
|
|
165
|
+
|
|
166
|
+
If you only want to update specific fields without replacing the entire item, use Bulk Patch:
|
|
167
|
+
|
|
168
|
+
**Endpoint**: `POST /wix-data/v2/bulk/items/patch`
|
|
169
|
+
|
|
170
|
+
> **Important**: This endpoint uses `patches` array with `fieldModifications`, NOT `dataItems`. Do not confuse with bulk update.
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
curl -X POST \
|
|
174
|
+
'https://www.wixapis.com/wix-data/v2/bulk/items/patch' \
|
|
175
|
+
-H 'Content-Type: application/json' \
|
|
176
|
+
-H 'Authorization: <AUTH>' \
|
|
177
|
+
-d '{
|
|
178
|
+
"dataCollectionId": "Products",
|
|
179
|
+
"patches": [
|
|
180
|
+
{
|
|
181
|
+
"dataItemId": "item-1",
|
|
182
|
+
"fieldModifications": [
|
|
183
|
+
{
|
|
184
|
+
"fieldPath": "onSale",
|
|
185
|
+
"action": "SET_FIELD",
|
|
186
|
+
"setFieldOptions": {
|
|
187
|
+
"value": true
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
> **Common error**: If you get `WDE0080: patches must not be empty`, you sent `dataItems` instead of `patches`. Use the format above.
|
|
197
|
+
|
|
198
|
+
## Truncate Collection
|
|
199
|
+
|
|
200
|
+
Remove all items from a collection (dangerous operation).
|
|
201
|
+
|
|
202
|
+
**Endpoint**: `POST /wix-data/v2/items/truncate`
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
curl -X POST \
|
|
206
|
+
'https://www.wixapis.com/wix-data/v2/items/truncate' \
|
|
207
|
+
-H 'Content-Type: application/json' \
|
|
208
|
+
-H 'Authorization: <AUTH>' \
|
|
209
|
+
-d '{
|
|
210
|
+
"dataCollectionId": "TestCollection"
|
|
211
|
+
}'
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
> **Warning**: This permanently deletes ALL items in the collection. Use with extreme caution.
|
|
215
|
+
|
|
216
|
+
## Aggregate Data
|
|
217
|
+
|
|
218
|
+
Perform calculations on collection data using a pipeline of sequential stages.
|
|
219
|
+
|
|
220
|
+
**Endpoint**: `POST /wix-data/v2/items/aggregate-pipeline`
|
|
221
|
+
|
|
222
|
+
**Count by Category**:
|
|
223
|
+
```bash
|
|
224
|
+
curl -X POST \
|
|
225
|
+
'https://www.wixapis.com/wix-data/v2/items/aggregate-pipeline' \
|
|
226
|
+
-H 'Content-Type: application/json' \
|
|
227
|
+
-H 'Authorization: <AUTH>' \
|
|
228
|
+
-d '{
|
|
229
|
+
"dataCollectionId": "Products",
|
|
230
|
+
"pipeline": {
|
|
231
|
+
"stages": [
|
|
232
|
+
{
|
|
233
|
+
"group": {
|
|
234
|
+
"groupIds": [
|
|
235
|
+
{"key": "category", "expression": {"fieldPath": "category"}}
|
|
236
|
+
],
|
|
237
|
+
"accumulators": [
|
|
238
|
+
{
|
|
239
|
+
"resultFieldName": "count",
|
|
240
|
+
"sum": {"expression": {"numeric": 1}}
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
}'
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Operation Comparison
|
|
251
|
+
|
|
252
|
+
| Operation | Use Case | Behavior |
|
|
253
|
+
|-----------|----------|----------|
|
|
254
|
+
| **Bulk Insert** | Add new items only | Fails if ID exists |
|
|
255
|
+
| **Bulk Update** | Update existing items | Fails if ID doesn't exist, replaces entire item |
|
|
256
|
+
| **Bulk Save** | Upsert (insert or update) | Creates or updates based on ID |
|
|
257
|
+
| **Bulk Patch** | Partial update | Only modifies specified fields |
|
|
258
|
+
|
|
259
|
+
## Related Documentation
|
|
260
|
+
|
|
261
|
+
- [Data Items API Reference](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction)
|
|
262
|
+
- [CMS Operations Best Practices](cms-data-items-crud.md)
|
|
263
|
+
- [CMS Schema Management](cms-schema-management.md)
|