Update MongoDB (NoSQL)

Synopsis

Updates one or more documents in a MongoDB collection.

Description

This operator updates one or more documents in the specified MongoDB collection. An update can thereby refer to the replacement of an document or to the modification of individual fields. The update consists of two parts: the query criteria to identify the document(s) and an update object that contains the new data.

The default update behavior of MongoDB is to replace entire documents. Special BSON operators are required to update individual fields. However, this operator tries to update individual fields by default to prevent data loss.

Input

  • criteria

    The JSON/BSON document to identify the document(s) to update.

  • update

    The JSON/BSON document containing the updated data. If using BSON operator such as "$set" ensure that the parameter "update individual fields" is disabled.

Output

  • criteria

    Pass through of the input criteria document (if any).

  • update

    Pass through of the input update document.

Parameters

  • mongodb_instance The MongoDB instance to be used for storing the documents. Range: configurable
  • write_concern The write concern which controls the acknowledgment of write operations by MongoDB. See MongoDB documentation for details. Range: selection
  • collection The MongoDB collection in which the documents are stored. Range: string
  • update_individual_fields If checked, the operator uses the MongoDB operator "$set" to update the fields of the provided update object without replacing other data. Otherwise, the operator simply replaces matching documents with the provided update document. Range: boolean
  • insert_unmatched_documents_(upsert) If checked, the operator adds the update document to the collection when no document matches the query criteria. Otherwise, the collections remains unchanged. Range: boolean
  • update_multiple_documents If checked, all documents that match the query criteria are updated. Otherwise, only the first match is updated. Range: boolean