SurrealDB Docs Logo

Enter a search query

.merge()

Modifies all records in a table, or a specific record, in the database.

Method Syntax
db.merge(thing, data)
Note

This function merges the current document / record data with the specified data. If no merge data is passed it will simply trigger an update.

Arguments

ArgumentsDescription
thing required

The table name or the specific RecordID to merge.

data optional

The document / record data to merge.

Example usage

# Update all records in a table await db.merge('person', { updated_at: datetime.datetime.utcnow() }) # Update a record with a specific ID await db.merge(RecordID('person', 'tobie'), { "updated_at": datetime.datetime.utcnow(), "settings": { "active": true, } })

Translated query

This function will run the following query in the database.

UPDATE $thing MERGE $data;