ByteChef LogoByteChef

MongoDB

MongoDB is a source-available, cross-platform, document-oriented database. Query, insert, update and delete documents in your collections.

Categories: Developer Tools

Type: mongodb/v1


Connections

Version: 1

custom

Properties

NameLabelTypeDescriptionRequired
connectionStringConnection StringSTRINGThe MongoDB connection string. Supports both standard (mongodb://) and SRV (mongodb+srv://) formats, as well as TLS and authentication options.true
databaseDatabaseSTRINGThe name of the database to connect to.true
usernameUsernameSTRINGUsername for authentication. Leave empty if credentials are in the connection string or no authentication is required.false
passwordPasswordSTRINGPassword for authentication. Leave empty if credentials are in the connection string or no authentication is required.false

Connection Setup

Official documentation

ByteChef connects to MongoDB using a standard connection string, so both MongoDB Atlas (SRV) and self-hosted deployments are supported.

MongoDB Atlas

  1. In MongoDB Atlas, open your cluster and click Connect → Drivers.
  2. Copy the SRV connection string (it looks like mongodb+srv://cluster0.example.mongodb.net).
  3. Under Database Access, create a database user (username and password).
  4. Under Network Access, allow your current IP address.
  5. Enter the connection string, database name and the user's credentials when creating the connection.

Self-hosted

  1. Use a standard connection string such as mongodb://host:27017.
  2. Provide the database name and, if authentication is enabled, the username and password.

TLS, X.509 and other advanced authentication options can be supplied directly in the connection string. See the connection string options for details.


Actions

Find

Name: find

Finds documents in a collection matching a filter.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to query.true
filterFilterOBJECT
Properties {}
The query filter as a JSON object. Leave empty to match all documents.false
projectionProjectionOBJECT
Properties {}
The fields to include or exclude as a JSON object, e.g. {"name": 1, "_id": 0}.false
sortSortOBJECT
Properties {}
The sort order as a JSON object, e.g. {"createdAt": -1} for descending.false
limitLimitINTEGERThe maximum number of documents to return. Leave empty for no limit.false

Example JSON Structure

{
  "label" : "Find",
  "name" : "find",
  "parameters" : {
    "collection" : "",
    "filter" : { },
    "projection" : { },
    "sort" : { },
    "limit" : 1
  },
  "type" : "mongodb/v1/find"
}

Output

Type: ARRAY

Items Type: OBJECT

Properties

NameTypeDescription
null

Output Example

[ { } ]

Insert One

Name: insertOne

Inserts a single document into a collection.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to insert into.true
documentDocumentOBJECT
Properties {}
The document to insert as a JSON object.true

Example JSON Structure

{
  "label" : "Insert One",
  "name" : "insertOne",
  "parameters" : {
    "collection" : "",
    "document" : { }
  },
  "type" : "mongodb/v1/insertOne"
}

Output

Type: OBJECT

Properties

NameTypeDescription
insertedIdSTRINGThe identifier of the inserted document.

Output Example

{
  "insertedId" : ""
}

Insert Many

Name: insertMany

Inserts multiple documents into a collection.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to insert into.true
documentsDocumentsARRAY
Items [{}]
The documents to insert, each as a JSON object.true

Example JSON Structure

{
  "label" : "Insert Many",
  "name" : "insertMany",
  "parameters" : {
    "collection" : "",
    "documents" : [ { } ]
  },
  "type" : "mongodb/v1/insertMany"
}

Output

Type: OBJECT

Properties

NameTypeDescription
insertedCountINTEGERThe number of documents inserted.
insertedIdsARRAY
Items [STRING]
The identifiers of the inserted documents.

Output Example

{
  "insertedCount" : 1,
  "insertedIds" : [ "" ]
}

Update One

Name: updateOne

Updates a single document in a collection matching a filter.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to update.true
filterFilterOBJECT
Properties {}
The query filter that selects the document to update, as a JSON object.true
updateUpdateOBJECT
Properties {}
The update to apply, as a JSON object using update operators, e.g. {"$set": {"status": "active"}}.true
upsertUpsertBOOLEAN
Options true, false
Whether to insert a new document when no document matches the filter.false

Example JSON Structure

{
  "label" : "Update One",
  "name" : "updateOne",
  "parameters" : {
    "collection" : "",
    "filter" : { },
    "update" : { },
    "upsert" : false
  },
  "type" : "mongodb/v1/updateOne"
}

Output

Type: OBJECT

Properties

NameTypeDescription
matchedCountINTEGERThe number of documents that matched the filter.
modifiedCountINTEGERThe number of documents that were modified.
upsertedIdSTRINGThe identifier of the upserted document, if any.

Output Example

{
  "matchedCount" : 1,
  "modifiedCount" : 1,
  "upsertedId" : ""
}

Update Many

Name: updateMany

Updates all documents in a collection matching a filter.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to update.true
filterFilterOBJECT
Properties {}
The query filter that selects the documents to update, as a JSON object.true
updateUpdateOBJECT
Properties {}
The update to apply, as a JSON object using update operators, e.g. {"$set": {"status": "active"}}.true
upsertUpsertBOOLEAN
Options true, false
Whether to insert a new document when no document matches the filter.false

Example JSON Structure

{
  "label" : "Update Many",
  "name" : "updateMany",
  "parameters" : {
    "collection" : "",
    "filter" : { },
    "update" : { },
    "upsert" : false
  },
  "type" : "mongodb/v1/updateMany"
}

Output

Type: OBJECT

Properties

NameTypeDescription
matchedCountINTEGERThe number of documents that matched the filter.
modifiedCountINTEGERThe number of documents that were modified.
upsertedIdSTRINGThe identifier of the upserted document, if any.

Output Example

{
  "matchedCount" : 1,
  "modifiedCount" : 1,
  "upsertedId" : ""
}

Delete One

Name: deleteOne

Deletes a single document from a collection matching a filter.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to delete from.true
filterFilterOBJECT
Properties {}
The query filter that selects the document to delete, as a JSON object.true

Example JSON Structure

{
  "label" : "Delete One",
  "name" : "deleteOne",
  "parameters" : {
    "collection" : "",
    "filter" : { }
  },
  "type" : "mongodb/v1/deleteOne"
}

Output

Type: OBJECT

Properties

NameTypeDescription
deletedCountINTEGERThe number of documents deleted.

Output Example

{
  "deletedCount" : 1
}

Delete Many

Name: deleteMany

Deletes all documents from a collection matching a filter.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to delete from.true
filterFilterOBJECT
Properties {}
The query filter that selects the documents to delete, as a JSON object.true

Example JSON Structure

{
  "label" : "Delete Many",
  "name" : "deleteMany",
  "parameters" : {
    "collection" : "",
    "filter" : { }
  },
  "type" : "mongodb/v1/deleteMany"
}

Output

Type: OBJECT

Properties

NameTypeDescription
deletedCountINTEGERThe number of documents deleted.

Output Example

{
  "deletedCount" : 1
}

Aggregate

Name: aggregate

Runs an aggregation pipeline against a collection.

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to aggregate.true
pipelinePipelineARRAY
Items [{}]
The aggregation pipeline, an ordered list of stages, each as a JSON object, e.g. {"$match": {"active": true}}.true

Example JSON Structure

{
  "label" : "Aggregate",
  "name" : "aggregate",
  "parameters" : {
    "collection" : "",
    "pipeline" : [ { } ]
  },
  "type" : "mongodb/v1/aggregate"
}

Output

Type: ARRAY

Items Type: OBJECT

Properties

NameTypeDescription
null

Output Example

[ { } ]

Triggers

New Document

Name: newDocument

Triggers when a new document is added to a collection.

Type: POLLING

Properties

NameLabelTypeDescriptionRequired
collectionCollectionSTRINGThe name of the collection to watch.true
orderByOrder By FieldSTRINGThe field used to detect new documents. Use a monotonically increasing field such as _id or a creation timestamp.true

Output

Type: ARRAY

Items Type: OBJECT

Properties

NameTypeDescription
null

JSON Example

{
  "label" : "New Document",
  "name" : "newDocument",
  "parameters" : {
    "collection" : "",
    "orderBy" : ""
  },
  "type" : "mongodb/v1/newDocument"
}

Additional Instructions

Filters, documents and pipelines

Properties such as Filter, Update, Document and the Pipeline stages are expressed as JSON objects that map directly to MongoDB's query language.

  • Filter uses query operators, e.g. {"age": {"$gte": 18}, "active": true}.
  • Update uses update operators, e.g. {"$set": {"status": "active"}, "$inc": {"loginCount": 1}}.
  • Pipeline is an ordered list of aggregation stages, e.g. [{"$match": {"active": true}}, {"$group": {"_id": "$country", "total": {"$sum": 1}}}].

New Document trigger

The New Document trigger detects new documents by tracking the highest value seen for the configured Order By Field. Use a monotonically increasing field such as _id (the default) or a creation timestamp so that newly inserted documents are reliably detected. The first poll records the current position and does not emit the existing backlog.

How is this guide?

Last updated on

On this page