->merge()
Modifies all records in a table, or a specific record, in the database.
Method Syntax
$db->merge($thing, $data)
This function merges the current document / record data with the specified data.
Arguments
| Arguments | Type | Description |
|---|
thing required | string, RecordId or StringRecordId
| The table name or the specific RecordId to merge. |
data optional | mixed | The document / record data to merge. |
Example usage
$people = $db->merge('person', [
"updated_at" => new Date(),
]);
$person = $db->merge(new RecordId('person', 'tobie'), [
"updated_at" => new Date(),
"settings" => [
"active" => true,
],
]);
$record = $db->merge(new RecordId('person', 'tobie'), [
"name" => 'Tobie',
]);
Translated query
This function will run the following query in the database.
UPDATE $thing MERGE $data;