Lodol Docs

MongoDB

API actions for the MongoDB integration.

MongoDB

Work with MongoDB databases, collections, and documents.


Delete documents

Delete documents from a MongoDB collection.

Parameters

ParameterTypeRequiredDescription
databasestringYesThe database that contains the collection.
collectionstringYesCollection containing the documents to delete.
filterobjectYesThe fields and values that identify which documents to delete.
manybooleanNoSet 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

ParameterTypeRequiredDescription
databasestringYesThe database name.
collectionstringYesThe collection name.
filterobjectNoThe fields and values that documents must match. Leave blank to return all documents.
limitnumberNoThe maximum number of documents to return.

Response

{
  "documents": [
    {
      "_id": "123",
      "name": "doc1"
    }
  ]
}

Insert document

Insert a document into a MongoDB collection.

Parameters

ParameterTypeRequiredDescription
databasestringYesThe database name.
collectionstringYesThe collection name.
documentobjectYesThe fields and values of the document to add.

Response

{
  "inserted_id": "abc123"
}

List collections

List all collections in a database.

Parameters

ParameterTypeRequiredDescription
databasestringYesThe 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

ParameterTypeRequiredDescription
databasestringYesThe database that contains the collection.
collectionstringYesCollection containing the documents to update.
filterobjectYesThe fields and values that identify which documents to update.
updatesobjectYesThe fields and new values to save on the matching documents.
manybooleanNoSet to true to update every matching document, or false to update only the first match.

Response

{
  "matched_count": 1,
  "modified_count": 1
}

On this page