Manage Items

You can use the Data Items API to create, update, and delete items in your collections. This guide covers the essential operations for managing your data.

Insert items

Use insert() to add a new item to a collection. The method takes the collection ID and an object containing the item data and returns the newly created item.

You can also specify your own custom _id when creating items. If you don't provide an _id field, the system automatically generates a random one for you.

This example creates a new real estate listing in the Listings collection:

Copy

You can also use save() which inserts a new item if it doesn't exist, or updates an existing item if it does.

Update items

Use update() to modify existing items. The method takes the collection ID, item ID, and the complete item object to update and returns the updated item.

Since update() replaces the entire item, you need to first have the existing item to avoid losing data in fields you don't intend to change:

This example updates the price and status of an existing real estate listing in the Listings collection:

Copy

You can also use patch() for partial updates, or save() which updates an existing item if it exists, or inserts a new item if it doesn't.

Remove items

Use remove() to delete items from a collection. The method takes the collection ID and the item ID and returns the deleted item.

This example removes a real estate listing from the Listings collection:

Copy

Bulk operations

For multiple items, use the bulk methods for better performance. Each singular operation has a bulk equivalent.

For example, to insert multiple items, use bulkInsert():

Copy

See also

Did this help?