collection.update

Mongo documentation

Modifies an existing document or documents in a collection. The method can modify specific fields of an existing document or documents or replace an existing document entirely, depending on the update parameter. By default, the update() method updates a single document. Set the multi option to update all documents that match the query criteria.

Arguments

  1. query (String|ObjectId|Object)

  2. update (Object): Update operations to be performed on the document

  3. [options] (Object)

if options.replaceOne is true, it will work like replaceOne.

  1. [callback] (function)

Returns

A promise.

Example

users.update({name: 'foo'}, {name: 'bar'})

results matching ""

    No results matching ""