merge
$merge
Merges the argument object into the input object (shallow). The argument fields take precedence over same-named fields in the input, consistent with the "apply to the value being passed through" pattern.
The input object is not mutated; a new object is returned.
Parameters
- Object of fields to merge (object, required): Key/value pairs to apply over the input.
Example
// Inject default fields into every output object
new Schema('object').transformer({$merge: {version: 1, active: true}})
// {id: 42} → {id: 42, version: 1, active: true}
// Overwrite a specific field in the result
new Schema('object').transformer({$merge: {status: 'normalized'}})
// {id: 1, status: 'raw'} → {id: 1, status: 'normalized'}