MongoDB
API actions for the MongoDB integration.
MongoDB
Work with MongoDB databases, collections, and documents.
Delete documents
Delete documents from a MongoDB collection.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | Yes | The database that contains the collection. |
collection | string | Yes | Collection containing the documents to delete. |
filter | object | Yes | The fields and values that identify which documents to delete. |
many | boolean | No | Set to true to delete every matching document, or false to delete only the first match. |
Response
{
"deleted_count": 1
}Find documents
Find documents in a MongoDB collection.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | Yes | The database name. |
collection | string | Yes | The collection name. |
filter | object | No | The fields and values that documents must match. Leave blank to return all documents. |
limit | number | No | The maximum number of documents to return. |
Response
{
"documents": [
{
"_id": "123",
"name": "doc1"
}
]
}Insert document
Insert a document into a MongoDB collection.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | Yes | The database name. |
collection | string | Yes | The collection name. |
document | object | Yes | The fields and values of the document to add. |
Response
{
"inserted_id": "abc123"
}List collections
List all collections in a database.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | Yes | The database name. |
Response
{
"collections": [
"users",
"orders"
]
}List databases
List all databases accessible with the connection.
Response
{
"databases": [
{
"name": "sample_db",
"sizeOnDisk": 1234
}
]
}Update documents
Update documents in a MongoDB collection.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database | string | Yes | The database that contains the collection. |
collection | string | Yes | Collection containing the documents to update. |
filter | object | Yes | The fields and values that identify which documents to update. |
updates | object | Yes | The fields and new values to save on the matching documents. |
many | boolean | No | Set to true to update every matching document, or false to update only the first match. |
Response
{
"matched_count": 1,
"modified_count": 1
}