MongoDB InsertOne

MongoDB InsertOne

Certified

Insert one document into MongoDB

Renders a BSON document from Flow variables and inserts it with insertOne. Requires write access; document may be provided as JSON/BSON string or map.

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

Insert a document with a map.

yaml
id: mongodb_insertone
namespace: company.team

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

Insert a document from a JSON string.

yaml
id: mongodb_insertone
namespace: company.team

tasks:
  - id: insertone
    type: io.kestra.plugin.mongodb.InsertOne
    connection:
      uri: "mongodb://root:example@localhost:27017/?authSource=admin"
    database: "my_database"
    collection: "my_collection"
    document: "{{ outputs.task_id.data | toJson }}"
Properties

MongoDB collection

MongoDB connection properties

Definitions
uri*Requiredstring

Connection string to MongoDB server

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

MongoDB database

Document to insert

BSON string or map rendered before execution.

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

Inserted document id

Whether the write was acknowledged

Unitcount

Number of documents inserted into MongoDB