CMS References & Relationships

Download skill
Copy

This recipe covers linking CMS collections together using reference fields.

Prerequisites

  1. Wix CMS enabled on the site
  2. At least two collections to link together
  3. API access with CMS permissions

Required APIs

  • Collections API: REST
  • Data Items API: REST

Reference Types

TypeField TypeRelationshipExample
Single ReferenceREFERENCEOne-to-one, Many-to-oneProduct → Category
Multi-ReferenceMULTI_REFERENCEOne-to-many, Many-to-manyProduct → Tags

Add a Single Reference Field

Endpoint: POST /wix-data/v2/collections/create-field

Copy

Add a Multi-Reference Field

Endpoint: POST /wix-data/v2/collections/create-field

Copy

Endpoint: POST /wix-data/v2/bulk/items/insert-references

Copy

Replace All References

Endpoint: POST /wix-data/v2/items/replace-references

Copy

Note: To remove all references, pass an empty array for newReferencedItemIds.

Remove References (Bulk)

Endpoint: POST /wix-data/v2/bulk/items/remove-references

Copy

Query with Referenced Items Expanded

Endpoint: POST /wix-data/v2/items/query

Copy

Reference Query Operators

OperatorDescriptionExample
$eqExact match (single reference){ "category": "id" }
$hasSomeHas at least one of{ "tags": { "$hasSome": ["id1", "id2"] } }
$hasAllHas all of{ "tags": { "$hasAll": ["id1", "id2"] } }
Did this help?