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
databasestringYesDatabase that hosts the collection.
collectionstringYesCollection containing the documents to delete.
filterobjectYesMongoDB filter document to match documents for removal.
manybooleanNoWhether to delete all matching documents (true) or just one (false).

Response

{
  "deleted_count": 1
}

Find documents

Find documents in a MongoDB collection.

Parameters

ParameterTypeRequiredDescription
databasestringYesThe database name.
collectionstringYesThe collection name.
filterobjectNoOptional query filter as a JSON object.
limitnumberNoOptional limit on number of documents returned.

Response

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

Insert document

Insert a document into a MongoDB collection.

Parameters

ParameterTypeRequiredDescription
databasestringYesThe database name.
collectionstringYesThe collection name.
documentobjectYesThe document to insert as a JSON object.

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
databasestringYesDatabase that hosts the collection.
collectionstringYesCollection containing the documents to update.
filterobjectYesMongoDB filter document to match rows.
updatesobjectYesFields to set on the matching documents.
manybooleanNoWhether to update all matching documents (true) or just one (false).

Response

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

On this page