Here are the details of the action function of MongoDB component.
Calculates aggregate values for data in a collection or view using a MongoDB aggregation pipeline.
Emit Individually: Emits one message per resulting document.Emit Batch: Emits documents grouped into arrays of size batchSize.Fetch All: Emits a single message containing an array of all resulting documents in memory.pipeline (required array): Array of aggregation pipeline stages (e.g., $match, $group, $sort, $project).batchSize (optional number): Page/batch size when Emit Batch is selected. Default: 10.{
"pipeline": [
{
"$match": {
"status": "active"
}
},
{
"$group": {
"_id": "$category",
"totalAmount": {
"$sum": "$amount"
},
"count": {
"$sum": 1
}
}
},
{
"$sort": {
"totalAmount": -1
}
}
],
"batchSize": 25
}
{
"result": {
"_id": "Electronics",
"totalAmount": 15420.5,
"count": 42
}
}
{
"result": [
{
"_id": "Electronics",
"totalAmount": 15420.5,
"count": 42
},
{
"_id": "Furniture",
"totalAmount": 8340.0,
"count": 19
}
]
}
Executes multiple write operations in a single database request. Operations are executed in the order provided.
operations (required array): Array of operation objects. Supported operations:
insertOne: { "document": { ... } }updateOne: { "filter": { ... }, "update": { ... }, "upsert": boolean }updateMany: { "filter": { ... }, "update": { ... }, "upsert": boolean }deleteOne: { "filter": { ... } }deleteMany: { "filter": { ... } }replaceOne: { "filter": { ... }, "replacement": { ... }, "upsert": boolean }{
"operations": [
{
"insertOne": {
"document": {
"sku": "ITEM-101",
"name": "Wireless Mouse",
"stock": 150
}
}
},
{
"updateOne": {
"filter": {
"sku": "ITEM-100"
},
"update": {
"$inc": {
"stock": -1
}
}
}
},
{
"deleteOne": {
"filter": {
"sku": "ITEM-099"
}
}
}
]
}
{
"result": {
"acknowledged": true,
"insertedCount": 1,
"matchedCount": 1,
"modifiedCount": 1,
"deletedCount": 1,
"upsertedCount": 0,
"insertedIds": {
"0": "64a296786751183ae1f615ed"
},
"upsertedIds": {}
}
}
Removes a specific document from a collection by its unique MongoDB identifier (_id).
id (required string): 24-character hexadecimal MongoDB _id string (e.g., "64a296786751183ae1f615ed"), or wrapped template syntax ObjectId('64a296786751183ae1f615ed').{
"id": "64a296786751183ae1f615ed"
}
{
"result": {
"acknowledged": true,
"deletedCount": 1
}
}
Deletes documents from a collection that match the specified filter criteria.
Please Note: Although named Delete By Unique Criteria, this action executes a MongoDB
deleteManycommand under the hood. Any document that matches the criteria will be deleted.
criteria (required object): Filter query. Supports ObjectId('...') syntax recursively on top-level fields, nested query operators ($eq, $in, $or, etc.), and arrays.{
"criteria": {
"status": "archived",
"customerId": "ObjectId('64a296786751183ae1f615ed')"
}
}
{
"result": {
"acknowledged": true,
"deletedCount": 3
}
}
Retrieves a single document from a collection based on its _id.
id (required string): 24-character hexadecimal MongoDB _id string (e.g., "64a296786751183ae1f615ed"), or wrapped template syntax ObjectId('64a296786751183ae1f615ed').{
"id": "64a296786751183ae1f615ed"
}
{
"result": {
"_id": "64a296786751183ae1f615ed",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"status": "active"
}
}
{
"result": null
}
Retrieves up to one document matching the specified unique criteria.
{} is emitted.Document not found is thrown.Allow zero results is true: emits {}.Allow zero results is false: throws Document not found.result wrapper).More than one document found.criteria (required object): Search filter. Supports ObjectId('...') syntax recursively on fields and nested query operators.{
"criteria": {
"email": "jane.doe@example.com"
}
}
{
"criteria": {
"_id": "ObjectId('64a296786751183ae1f615ed')"
}
}
{
"_id": "64a296786751183ae1f615ed",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"status": "active"
}
{}
Finds multiple documents matching the given search criteria.
Emit Individually: Emits one message per document with groupInfo.Emit Batch: Emits arrays of documents chunked by batchSize with groupInfo.Fetch All: Emits a single message containing all matching documents.criteria (required object): Search filter. Supports ObjectId('...') syntax recursively on fields and nested query operators.limit (optional number): Maximum number of documents to return. Set to 0 or omit for unlimited.project (optional object): Specifies which fields to include (1) or exclude (0).batchSize (optional number): Chunk size when Emit Batch is selected. Default: 10.Please Note: In MongoDB projections, you cannot combine field inclusion (
1) and exclusion (0) in the same query, with the sole exception of the_idfield (e.g.{ "name": 1, "email": 1, "_id": 0 }).
{
"criteria": {
"status": "active"
},
"limit": 50
}
{
"criteria": {
"department": "Engineering"
},
"project": {
"name": 1,
"email": 1,
"_id": 0
},
"limit": 100,
"batchSize": 20
}
{
"result": {
"_id": "64a296786751183ae1f615ed",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"status": "active"
}
}
{
"result": [
{
"_id": "64a296786751183ae1f615ed",
"name": "Jane Doe",
"email": "jane.doe@example.com",
"status": "active"
},
{
"_id": "64a296786751183ae1f615ee",
"name": "John Smith",
"email": "john.smith@example.com",
"status": "active"
}
]
}
Updates one or more documents matching the specified criteria.
criteria (required object): Filter used to select documents to update. Supports ObjectId('...') syntax recursively on fields and nested query operators.update (required object): MongoDB update operations (e.g. $set, $inc, $unset, $push).{
"criteria": {
"department": "Sales",
"status": "active"
},
"update": {
"$set": {
"commissionRate": 0.15,
"lastReviewed": "2026-09-01T00:00:00.000Z"
},
"$inc": {
"reviewCount": 1
}
}
}
{
"result": {
"acknowledged": true,
"insertedId": null,
"matchedCount": 3,
"modifiedCount": 3,
"upsertedCount": 0,
"upsertedId": null
}
}
Updates an existing document or inserts a new document based on the provided document ID and payload.
id (optional string): Raw 24-character hexadecimal MongoDB _id of the document to upsert, or wrapped with ObjectId('...').
_id. If found, it updates the document; if not found, it inserts a new document with this _id._id.{
"id": "64a296786751183ae1f615ed",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"role": "Lead Architect",
"skills": ["Node.js", "MongoDB", "Kubernetes"]
}
{
"result": {
"_id": "64a296786751183ae1f615ed",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"role": "Lead Architect",
"skills": ["Node.js", "MongoDB", "Kubernetes"]
}
}
Updates an existing document or inserts a new one based on unique matching criteria.
criteria (required object): Unique matching filter. Supports ObjectId('...') syntax recursively on fields and nested query operators.value (required object): Fields to apply via $set when updating or inserting the document.{
"criteria": {
"email": "alice.johnson@example.com"
},
"value": {
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"role": "Principal Architect",
"department": "Platform Engineering",
"status": "active"
}
}
{
"result": {
"_id": "64a296786751183ae1f615ed",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"role": "Principal Architect",
"department": "Platform Engineering",
"status": "active"
}
}
Click here to learn more about the elastic.io iPaaS