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 | Database that hosts the collection. |
collection | string | Yes | Collection containing the documents to delete. |
filter | object | Yes | MongoDB filter document to match documents for removal. |
many | boolean | No | Whether to delete all matching documents (true) or just one (false). |
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 | Optional query filter as a JSON object. |
limit | number | No | Optional limit on number of documents returned. |
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 document to insert as a JSON object. |
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 | Database that hosts the collection. |
collection | string | Yes | Collection containing the documents to update. |
filter | object | Yes | MongoDB filter document to match rows. |
updates | object | Yes | Fields to set on the matching documents. |
many | boolean | No | Whether to update all matching documents (true) or just one (false). |
Response
{
"matched_count": 1,
"modified_count": 1
}