Search
Search
addItems
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 }, [aboutField.id]: { type: "formattedText", value: "Practicing **Competitive** Lawn Mowing", contentType: "markdown" // other values can be: "html" (default), or "auto" } }, }, ])
Important: currently, calling
addItemswith existing item ids merges the provided field data with the existing items' current field data, meaning any omitted fields remain unchanged.In version 4.0.0, this behavior will change - calling
addItemswith existing item ids will fully replace those items with the provided field data, meaning any fields not explicitly included will be removed. For example, if you initially add an item with anamefield and anagefield, and later calladdItemsagain with the same id but only provide thenamefield, the previously setagefield will be removed.To avoid unexpected behaviour when migrating between 3.X.X and 4.0.0, always include all fields when updating existing items.
Parameters
items: ManagedCollectionItemInput[]– An array of Items to add or update.
Returns
Promise<void>