.Merge<T>()
Modifies all records in a table, or a specific record.
Method Syntaxawait db.Merge<T>(resource, data)
NoteThis function merges the current document / record data with the specified data.
Arguments | Description | ||
---|---|---|---|
thing required | The table name or the specific | ||
data optional | The data with which to modify the records. | ||
cancellationToken optional | The cancellationToken enables graceful cancellation of asynchronous operations. |
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);