MongoDB Find

MongoDB Find

Certified

Query documents from MongoDB

Executes find on a collection with optional projection, sort, skip, and limit. Filter/projection/sort accept BSON strings or maps rendered from Flow variables. Results are fetched in-memory into the outputs by default. Set store to true for large results, which writes them as Ion to internal storage.

yaml
type: io.kestra.plugin.mongodb.Find
yaml
id: mongodb_find
namespace: company.team

tasks:
  - id: find
    type: io.kestra.plugin.mongodb.Find
    connection:
      uri: "mongodb://root:example@localhost:27017/?authSource=admin"
    database: "my_database"
    collection: "my_collection"
    filter:
      _id:
        $oid: 60930c39a982931c20ef6cd6

Find documents in MongoDB based on a filter condition using MongoDB Query Language.

yaml
id: filter_mongodb
namespace: company.team

tasks:
  - id: filter
    type: io.kestra.plugin.mongodb.Find
    connection:
      uri: mongodb://host.docker.internal:27017/
    database: local
    collection: pokemon
    store: true
    filter:
      base_experience:
        $gt: 100
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-mongodb --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

MongoDB collection

MongoDB connection properties

Definitions
uri*string

Connection string to MongoDB server

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

MongoDB database

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.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset 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.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Query filter

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 '{"deletedAt": null}'.

Limit

Maximum documents returned.

DefaultHEX
Possible Values
HEXEXTENDED_JSON

ObjectId format

HEX returns ObjectIds as bare hex strings, as before. EXTENDED_JSON returns them as $oid wrappers, which Load writes back as ObjectIds, so a Find with store: true followed by Load keeps the type. Under EXTENDED_JSON, rows[0]._id becomes a map with $oid, for example {"$oid": "60930c39a982931c20ef6cd6"}. Defaults to HEX.

Projection

BSON string or map selecting fields to return. A null map entry is dropped when the flow is parsed; pass a JSON string when a null is needed.

Skip

Documents to skip before returning results.

Sort

BSON string or map defining sort order. A null map entry is dropped when the flow is parsed; pass a JSON string when a null is needed.

Defaultfalse

Store results

When true, writes the results as Ion to internal storage and returns their URI. When false, the default, returns every document in rows, held in memory and saved in the execution. Keep false for small results: Kestra rejects task results above kestra.queue.message-protection.limit (1 MiB by default since 2.0), and the task logs a warning when the rows pass 1 MiB.

Result rows

Present when store is false.

Rows fetched

Formaturi

Stored result URI

Internal storage URI when store is true.

Unitcount

Number of documents fetched from MongoDB