There are a few common cases where I think the query language should be extended to support partial updates on documents without having to fetch their existing values first.
Currently such operations require fetching all relevant documents, assigning the new field(s) client-side, and then applying all the updates to the server via .replace(...).
.assign([<field>, <value>] | <object>)
Apply updates across multiple documents.
collection.assign(<field>, <value>)
collection.assign({ field: <value> })
collection.findAll(...).assign({ field: <value> })
.increment(<field>, <by=1>)
.decrement(<field>, <by=1>)
Increment or decrement values on one or many documents without knowledge of the existing values.
collection.increment(<field>)
collection.decrement(<field>, 3)
collection.find(...).increment(<field>, 2)
There are a few common cases where I think the query language should be extended to support partial updates on documents without having to fetch their existing values first.
Currently such operations require fetching all relevant documents, assigning the new field(s) client-side, and then applying all the updates to the server via
.replace(...)..assign([<field>, <value>] | <object>)Apply updates across multiple documents.
.increment(<field>, <by=1>).decrement(<field>, <by=1>)Increment or decrement values on one or many documents without knowledge of the existing values.