MongoDB Update

MongoDB Update

Certified

Update or replace MongoDB documents

Runs MongoDB replaceOne, updateOne, or updateMany on a collection. Defaults to UPDATE_ONE; both filter and document accept BSON maps or strings and are rendered from Flow variables. Requires write access; upserts are not exposed.

yaml
type: io.kestra.plugin.mongodb.Update

Replace a document.

yaml
id: mongodb_update
namespace: company.team

tasks:
  - id: update
    type: io.kestra.plugin.mongodb.Update
    connection:
      uri: "mongodb://root:example@localhost:27017/?authSource=admin"
    database: "my_database"
    collection: "my_collection"
    operation: "REPLACE_ONE"
    document:
      _id:
        $oid: 60930c39a982931c20ef6cd6
      name: "John Doe"
      city: "Paris"
    filter:
      _id:
        $oid: 60930c39a982931c20ef6cd6

Update a document.

yaml
id: mongodb_update
namespace: company.team

tasks:
  - id: update
    type: io.kestra.plugin.mongodb.Update
    connection:
      uri: "mongodb://root:example@localhost:27017/?authSource=admin"
    database: "my_database"
    collection: "my_collection"
    filter:
      _id:
        $oid: 60930c39a982931c20ef6cd6
    document: '{"$set": { "tags": ["blue", "green", "red"]}}'
Properties

MongoDB collection

MongoDB connection properties

Definitions
uri*Requiredstring

Connection string to MongoDB server

URL format like mongodb://mongodb0.example.com: 27017

MongoDB database

Update payload or replacement document

BSON string or map rendered before execution.

Query filter

BSON string or map rendered before execution; selects documents to update.

DefaultUPDATE_ONE
Possible Values
REPLACE_ONEUPDATE_ONEUPDATE_MANY

Update operation

One of UPDATE_ONE (default), UPDATE_MANY, or REPLACE_ONE.

Reference (ref) of the pluginDefaults to apply to this task.

Default0

The number of documents matched by the query

The number of documents modified by the update

Upserted document id

Null unless MongoDB created a document during the write.

Whether the write was acknowledged

Unitcount

Number of documents updated in MongoDB