Search
addItems
Add new items or update existing ones if their IDs match.
await collection.addItems([ { id: "1", slug: "item-1", fieldData: { [nameField.id]: { type: "string", value: "Eric" }, [ageField.id]: { type: "number", value: 47 }, specs: { type: "array", value: [{ id: "width", fieldData: { label: { type: "string", value: "Width" }, amount: { type: "number", value: 120 }, }, }], }, }, }, ])
This method performs an upsert: items with matching IDs are updated, new IDs are inserted.
Each item requires an id and slug. Custom field data is provided via the fieldData object, using field IDs as keys.
Updating an existing item merges its top-level field data, leaving omitted fields unchanged. A supplied array value replaces the complete array and each array item's field data. Include all array items and nested values to keep; use value: [] to clear the array.
Every array item requires a stable id of your choice, unique within that array value. Reuse IDs across syncs and reordering to preserve matching localized values. Nested fieldData uses the IDs from the array's fields.
Parameters
items:ManagedCollectionItemInput[]– An array of items to add or update.
Returns
Promise<void>