Astra DB icon

Astra DB

Interact with DataStax Astra DB collections for document operations

Find And Update Document

AI-generated

Summary

Finds a document in Astra DB based on provided criteria and updates it with new data.

Inputs

  • keyspace (required) — The name of the Astra DB keyspace.
  • collection (required) — The name of the Astra DB collection.
  • filter (required) — JSON criteria to locate the document to update.
  • update (required) — JSON operations defining how to update the found document.
  • options — Additional options such as upserting if not found or specifying which version of the document to return.

Output shape

the updated document

Returns the document either before or after the update based on the 'returnDocument' option.

Examples

Example 1: An example scenario where a user wants to update the price of a product in the inventory collection if the product is found by its ID.

Set 'keyspace' to 'store', 'collection' to 'inventory', 'filter' to '{"id":"123"}', and 'update' to '{"price": 19.99}' with default options.

Discussion