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 },
    },
  },
])

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.

Currently, calling addItems with 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 to fully replace items, removing any fields not explicitly included. Always include all fields when updating existing items to avoid unexpected behavior.

Parameters

Returns

  • Promise<void>