InsertOne InsertOne

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

Insert a document into a MongoDB collection.

Examples

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 | json }}"

Properties

collection

  • Type: string
  • Dynamic: ✔️
  • Required: ✔️

MongoDB collection.

connection

MongoDB connection properties.

database

  • Type: string
  • Dynamic: ✔️
  • Required: ✔️

MongoDB database.

document

  • Type: object
  • Dynamic: ✔️
  • Required: ✔️

MongoDB document.

Can be a BSON string, or a map.

Outputs

insertedId

  • Type: string
  • Required:

The inserted ID.

wasAcknowledged

  • Type: boolean
  • Required:

Whether the write was acknowledged.

Definitions

io.kestra.plugin.mongodb.MongoDbConnection

Properties

uri
  • Type: string
  • Dynamic: ✔️
  • Required: ✔️
  • Min length: 1

Connection string to MongoDB server.

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

Was this page helpful?