Update/Upsert documents in the memory db. They are found first using
find
and then updated. Documents updates can be customized
by using an $update
function.
function update(
object fields,
[object update|function $update],
[object options|function $update]
)
arguments
fields
type object, document(s) fields to lookupupdate
type object, which fields to update on document(s) found$update
type function, customizes how to update fieldsoptions
type object, modifies how to do the updateoptions. Same they are for find
plus
$upsert
type boolean, wether to insert
if no documents found$update
type function, customizer for the update$update(doc, update)
arguments
doc
document found using fields
update
same object given as argumentdefaults
options.$update
to merge properties of doc
with update
returns this