MongoDB

Send MongoDB queries with the MongoDB built-in.
Execute MongoDB queries with your configured MongoDB resource. The following MongoDB methods are available as built-ins.

Find

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.
opts.skipnumbernullHow many results to skip.
opts.limitnumbernullHow many results to reurn.

Output

FieldTypeDescription
output[]objectA list of MongoDB documents.
Example
json
Copied
1
[{ "_id": "62c4caa466499db2981e496e", "fruit": "apple" }]

FindOne

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
outputobjectA MongoDB document. Empty if there were no results.
Example
json
Copied
1
{ "_id": "62c4caa466499db2981e496e", "fruit": "apple" }

UpdateOne

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
updateobjectRequiredThe documents to update.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.upsertbooleanfalseSpecifies whether to create a new document if one does not exist.

Output

FieldTypeDescription
output.MatchedCountnumberThe number of documents matching the filter.
output.ModifiedCountnumberThe number of documents modified.
output.UpsertedCountnumberThe number of documents upserted. 0 if upsert is false.
output.UpsertedIDstring | nullThe _id for the upserted document. null if upsert is false.
Example
json
Copied
1
{
2
"MatchedCount": 1,
3
"ModifiedCount": 1,
4
"UpsertedCount": 0,
5
"UpsertedID": null
6
}

UpdateMany

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
updateobjectRequiredThe documents to update.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.upsertbooleanfalseSpecifies whether to create a new document if one does not exist.

Output

FieldTypeDescription
output.MatchedCountnumberThe number of documents matching the filter.
output.ModifiedCountnumberThe number of documents modified.
output.UpsertedCountnumberThe number of documents upserted. 0 if upsert is false.
output.UpsertedIDstring | nullThe _id for the upserted document. null if upsert is false.
Example
json
Copied
1
{
2
"MatchedCount": 2,
3
"ModifiedCount": 2,
4
"UpsertedCount": 0,
5
"UpsertedID": null
6
}

FindOneAndUpdate

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
updateobjectRequiredThe documents to update.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
outputobjectReturns the original document.

FindOneAndReplace

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
updateobjectRequiredThe documents to update.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
outputobjectReturns the original document.

InsertOne

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
documentobjectRequiredThe document to insert.

Output

FieldTypeDescription
output.InsertedIDstringThe _id of the inserted document.
Example
json
Copied
1
{
2
"InsertedID": "62c4caa466499db2981e496e"
3
}

InsertMany

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
documents[]objectRequiredThe documents to insert.

Output

FieldTypeDescription
output.InsertedIDsstring[]A list containing _id values for each inserted document
Example
json
Copied
1
{
2
"InsertedIDs": ["63250df2b895dfd52a6420c3", "63250df2b895dfd52a6420c4"]
3
}

FindOneAndDelete

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
outputobjectReturns the deleted document.

DeleteOne

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
output.DeletedCountnumberThe number of deleted documents.

DeleteMany

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
opts.filterobjectnullOptional filter criteria. Returns all documents if filter is not provided.
opts.projectionobjectnullSpecify which fields to return in the results.
opts.sortobjectnullSpecify the sort order of results.

Output

FieldTypeDescription
output.DeletedCountnumberThe number of deleted documents.
Example
json
Copied
1
{
2
"DeletedCount": 4
3
}

Aggregate

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
pipeline[]objectRequiredSee aggregation-pipeline.

Output

FieldTypeDescription
output[]objectA list of documents produced by the final stage of the aggregation pipeline operation.

CountDocuments

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
collectionstringRequiredThe MongoDB collection.
filterobjectRequiredCriteria to filter by.

Output

FieldTypeDescription
outputnumberThe count of documents that match the query .

Distinct

Request

FieldTypeDefaultDescription
mongodbResourcestringRequiredSlug of REST resource to use. See Resources.
fieldstringRequiredThe field to count.
collectionstringRequiredThe MongoDB collection.
filterobjectRequiredCriteria to filter by.

Output

FieldTypeDescription
output[]objectA list of distinct values for a specified field across the searched collection or view.