MongoDB

App · Databases · 11 actions

Find, insert, update, replace, delete and aggregate documents in your MongoDB collections, and manage Atlas Search indexes.

Actions

ActionWhat it does
Aggregate documentsGroup, count, total or reshape a collection's documents with an aggregation pipeline, such as orders per status.
Create search indexAdd an Atlas Search or vector search index to a collection.
Delete documentsDelete documents from a MongoDB collection.
Delete search indexDelete a search index from a collection.
Find and replace documentReplace the first document that matches with new fields, keeping its _id, and return the new version.
Find and update documentUpdate the first document that matches and return it as it is after the change.
Find documentsFind documents in a MongoDB collection, optionally filtered and limited.
Insert documentsInsert one or more documents into a MongoDB collection.
List search indexesList a collection's Atlas Search indexes and whether each is ready to search.
Update documentsUpdate documents in a MongoDB collection.
Update search indexReplace a search index's settings.

Aggregate documents

Group, count, total or reshape a collection's documents with an aggregation pipeline, such as orders per status. Only reads: stages that save results ($out, $merge) are refused.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection to read from.
PipelinepipelinelistRequired
The stages, in order, such as [{"$match": {"status": "paid"}}, {"$group": {"_id": "$customer", "total": {"$sum": "$amount"}}}].
Limitlimitnumber
The most documents to return, up to 1000. Defaults to 1000.From 1 to 1000.

Outputs

countnumber
Number of documents returned.
documentslist
What the pipeline produced, with any _id as text.
Example output
{
  "count": 1,
  "documents": [
    {
      "_id": "paid",
      "count": 12
    }
  ]
}

Create search index

Add an Atlas Search or vector search index to a collection. Atlas builds it in the background; 'List search indexes' shows when it is ready. Needs MongoDB Atlas.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection to index. It must already exist.
Index namenametextRequired
The search index's name, such as default.
Index settingsdefinitionobjectRequired
The index's settings as MongoDB Atlas writes them, such as {"mappings": {"dynamic": true}} to search every field, or for vector search {"fields": [{"type": "vector", "path": "embedding", "numDimensions": 1536, "similarity": "cosine"}]}.
Index typeindex_typetext
Search for words and phrases, or vector search for embeddings. Defaults to search.One of: search (Search (words and phrases)), vectorSearch (Vector search (embeddings)). Default: search.

Outputs

createdtrue/false
True once Atlas has accepted it.
nametext
The new index's name.
typetext
search or vectorSearch.
Example output
{
  "created": true,
  "name": "default",
  "type": "search"
}

Delete documents

Delete documents from a MongoDB collection.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
Collection containing the documents to delete.
FilterfilterobjectRequired
A MongoDB query object identifying which documents to delete, e.g. {"_id": "64b0000000000000000000aa"}. Must be non-empty; to delete every document deliberately, use {"_id": {"$exists": true}}.
Delete all matchesmanytrue/false
Set to true to delete every matching document, or false to delete only the first match.Default: false.

Outputs

deleted_countnumber
Number of deleted documents.
Example output
{
  "deleted_count": 1
}

Delete search index

Delete a search index from a collection. The documents are untouched. Needs MongoDB Atlas.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection the index is on.
Index namenametextRequired
The search index's name, such as default.

Outputs

droppedtrue/false
True once Atlas has accepted the deletion.
nametext
The deleted index's name.
Example output
{
  "dropped": true,
  "name": "default"
}

Find and replace document

Replace the first document that matches with new fields, keeping its _id, and return the new version. Fields left out are removed.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
Collection containing the document to replace.
FilterfilterobjectRequired
A MongoDB query object for the document to replace, e.g. {"sku": "A-100"}.
New documentreplacementobjectRequired
Every field the document should have from now on, e.g. {"sku": "A-100", "price": 12}.
Add if missingupserttrue/false
Set to true to add a new document when none matches, made from the new document. Off by default.Default: false.

Outputs

documentobject
The document as it is now, with its _id as text; empty when none matched.
foundtrue/false
True when a document matched (or was added).
Example output
{
  "document": {
    "_id": "64b0000000000000000000aa",
    "price": 12,
    "sku": "A-100"
  },
  "found": true
}

Find and update document

Update the first document that matches and return it as it is after the change.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
Collection containing the document to update.
FilterfilterobjectRequired
A MongoDB query object for the document to update, e.g. {"email": "ada@example.com"}.
UpdatesupdatesobjectRequired
The fields and new values to save (applied with MongoDB's $set), e.g. {"status": "archived"}.
Add if missingupserttrue/false
Set to true to add a new document when none matches, made from the filter and the updates. Off by default.Default: false.

Outputs

documentobject
The document as it is now, with its _id as text; empty when none matched.
foundtrue/false
True when a document matched (or was added).
Example output
{
  "document": {
    "_id": "64b0000000000000000000aa",
    "email": "ada@example.com",
    "status": "archived"
  },
  "found": true
}

Find documents

Find documents in a MongoDB collection, optionally filtered and limited.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection to read from.
Filterfilterobject
A MongoDB query object of the fields and values documents must match, e.g. {"status": "active"}. Leave blank to return every document. Query operators such as $gt, $in and $regex are supported.
Limitlimitnumber
The maximum number of documents to return.At least 1.

Outputs

countnumber
Number of documents returned.
documentslist
The matching documents. Each document's _id is returned as a string.
Example output
{
  "count": 1,
  "documents": [
    {
      "_id": "64b0000000000000000000aa",
      "active": true,
      "name": "Ada"
    }
  ]
}

Insert documents

Insert one or more documents into a MongoDB collection.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection to insert into. Pick an existing collection, or reference a name from an earlier step to create one on the fly (MongoDB creates the collection automatically on first insert).
DocumentsdocumentslistRequired
The documents to insert. Each item is an object of field names and values. Omit _id to let MongoDB generate one.

Outputs

inserted_countnumber
Number of documents inserted.
inserted_idslist
The _id of each inserted document, as strings.
Example output
{
  "inserted_count": 1,
  "inserted_ids": [
    "64b0000000000000000000bb"
  ]
}

List search indexes

List a collection's Atlas Search indexes and whether each is ready to search. Needs MongoDB Atlas.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection whose search indexes to list.
Index namenametext
Only the index with this name. Leave empty for all.

Outputs

countnumber
Number of search indexes.
indexeslist
The search indexes.
Example output
{
  "count": 1,
  "indexes": [
    {
      "definition": {
        "mappings": {
          "dynamic": true
        }
      },
      "id": "6524096020da840844a4c4a7",
      "name": "default",
      "queryable": true,
      "status": "READY",
      "type": "search"
    }
  ]
}

Update documents

Update documents in a MongoDB collection.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
Collection containing the documents to update.
FilterfilterobjectRequired
A MongoDB query object identifying which documents to update, e.g. {"email": "ada@example.com"}. Must be non-empty; to update every document deliberately, use {"_id": {"$exists": true}}.
UpdatesupdatesobjectRequired
The fields and new values to save on each matching document (applied with MongoDB's $set), e.g. {"status": "archived"}.
Update all matchesmanytrue/false
Set to true to update every matching document, or false to update only the first match.Default: false.

Outputs

matched_countnumber
Number of matched documents.
modified_countnumber
Number of modified documents.
Example output
{
  "matched_count": 1,
  "modified_count": 1
}

Update search index

Replace a search index's settings. Atlas rebuilds it in the background and keeps the old one searchable meanwhile. Needs MongoDB Atlas.

Inputs

DatabasedatabasetextRequired
The database that contains the collection.
CollectioncollectiontextRequired
The collection the index is on.
Index namenametextRequired
The search index's name, such as default.
Index settingsdefinitionobjectRequired
The index's settings as MongoDB Atlas writes them, such as {"mappings": {"dynamic": true}} to search every field, or for vector search {"fields": [{"type": "vector", "path": "embedding", "numDimensions": 1536, "similarity": "cosine"}]}.

Outputs

nametext
The index's name.
updatedtrue/false
True once Atlas has accepted the new settings.
Example output
{
  "name": "default",
  "updated": true
}

On this page