SurrealDB Docs Logo

Enter a search query

.Merge<T>()

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

Method Syntax
await db.Merge<T>(resource, data)
Note

This function merges the current document / record data with the specified data.

Arguments

ArgumentsDescription
thing required

The table name or the specific RecordId to merge.

data optional

The data with which to modify the records.

cancellationToken optional

The cancellationToken enables graceful cancellation of asynchronous operations.

Example usage

Merging data within a single record
// Only changes the fields specified in the merge object var merge = new PersonMerge { Id = ("person", "tobie"), Settings = new Settings { Active = true, Marketing = false, }, }; var result = await db.Merge<PersonMerge, Person>(merge); // Only changes the fields specified in the Dictionary var data = new Dictionary<string, object> { { "tags", new List<string> { "developer", "engineer" } } }; var result = await db.Merge<Person>(("person", "tobie"), data);
Merging data for every record in a table
// Only changes the fields specified in the merge object var merge = new PersonMerge { Settings = new Settings { Active = true, Marketing = false, }, }; var result = await db.Merge<PersonMerge, Person>("person", merge); // Only changes the fields specified in the Dictionary var data = new Dictionary<string, object> { { "tags", new List<string> { "developer", "engineer" } } }; var result = await db.Merge<Person>("person", data);

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install