
MongoDB InsertOne
CertifiedInsert one document into MongoDB
MongoDB InsertOne
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.
type: io.kestra.plugin.mongodb.InsertOneExamples
Insert a document with a map.
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.
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
collection *string
MongoDB collection
connection *
MongoDB connection properties
io.kestra.plugin.mongodb.MongoDbConnection
Connection string to MongoDB server
URL format like mongodb://mongodb0.example.com: 27017
database *string
MongoDB database
document *object
Document to insert
BSON string or map rendered before execution.
A null map entry is dropped when the flow is parsed; pass a JSON string when a null is needed, for example '{"_id": 1, "k": null}'.
assets
Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.
io.kestra.core.models.assets.AssetsDeclaration
IGNOREFAILWARNAsset failure behavior
Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.
Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.
The assets consumed as inputs.
io.kestra.core.models.assets.AssetIdentifier
1The assets produced as outputs.
io.kestra.plugin.ee.assets.Dataset
1150{}1150io.kestra.plugin.ee.assets.File
1150{}1150io.kestra.plugin.ee.assets.Table
1150{}1150io.kestra.plugin.ee.assets.VM
1150{}1150io.kestra.core.models.assets.External
1150{}1150io.kestra.core.models.assets.Custom
11501Custom asset type
{}1150Outputs
insertedId string
Inserted document id
The _id of the inserted document, as a string:
- ObjectId: its hex string
- String: as is
- Int32, Int64, Double or Decimal128: the number
- UUID (Binary subtype 4): its canonical string
- any other type, including a legacy UUID (Binary subtype 3) or a document: its relaxed MongoDB Extended JSON, such as
{"a": 1}
With an unacknowledged write concern (w=0) it is the id that was sent, the insert itself is not confirmed.
wasAcknowledged boolean
Whether the write was acknowledged
Metrics
inserted.count counter
countNumber of documents inserted into MongoDB