Skip to content

Proposal: support basic update operations without fetching documents first #576

@marshall007

Description

@marshall007

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions