Start typing to search.

Connector Reference

MongoDB

View Markdown

Configure the mongodb connector to query, aggregate, and write MongoDB collections with Extended JSON ObjectId and date coercion.

MongoDB

The mongodb connector queries, aggregates, and writes documents in a MongoDB database.

When to use it

Use mongodb as a document-store source or destination, or as a lookup and staging store when your data is already in MongoDB. Filters and aggregation pipelines use native MongoDB query syntax.

Configuration

Key Type Required Default Description
connection_string string Yes MongoDB connection string (stored as a secret)
database string Yes Database name

Methods

Method Arguments Returns Behavior
find collection (required), filter, projection, sort, limit, skip array Streams documents from the driver cursor one at a time
find_one collection (required), filter, projection object Returns a single document
count collection (required), filter object Returns { count } of matching documents
insert_one collection (required), data (required) object Inserts a single document
update_one collection (required), filter (required), update (required), upsert object Updates one document; upsert: true inserts when nothing matches
update_many collection (required), filter (required), update (required), upsert object Updates all matching documents
delete_one collection (required), filter (required) object Deletes one document
delete_many collection (required), filter (required) object Deletes all matching documents
aggregate collection (required), pipeline (required) array Streams aggregation results from the driver cursor
list_collections array Returns { name, type } for every collection and view in the database

Example

name: export_open_tickets
connectors:
  source:
    type: mongodb
steps:
  - name: read_tickets
    type: call_method
    config: |
      {
        "connector": "source",
        "method": "find",
        "args": {
          "collection": "tickets",
          "filter": { "status": "open" },
          "sort": { "created_at": -1 }
        }
      }

The matching connectors.yaml entry for CLI runs:

source:
  type: mongodb
  config:
    connection_string: ${MONGODB_CONNECTION_STRING}
    database: helpdesk

Behavior notes

  • Filters, update documents, and pipelines are coerced from Extended JSON before execution: { "$oid": "..." } values become ObjectId instances (invalid hex fails with Invalid ObjectId hex), and $date values become Date objects. This lets YAML/JSON task configs express BSON types.
  • find and aggregate return async iterators over the driver cursor, so large result sets stream with backpressure instead of buffering.
  • update_one and update_many take a MongoDB update document (for example { "$set": { ... } }) in update.