Mongo Query Syntax

Appsmith uses the database command syntax to query MongoDB

Find Query

Syntax

{
"find": <string>,
"filter": <document>,
"sort": <document>,
"projection": <document>,
"skip": <int>,
"limit": <int>
}

Example

{
"find": "restaurants",
"filter": { "rating": { "$gte": 9 }, "cuisine": "italian" },
"projection": { "name": 1, "rating": 1, "address": 1 },
"sort": { "name": 1 },
"limit": 5
}

Update Query

Syntax

{
"update": <collection>,
"updates": [
{
"q": <query>,
"u": <document or pipeline>
}
]
}

****Complete list of fields****

Example

{
"update": "members",
"updates": [
{
"q": { },
"u": { "$set": { "status": "A" }, "$inc": { "points": 1 } },
"multi": true
}
]
}

Insert Query

Syntax

{
"insert": <collection>,
"documents": [ <document>, <document>, ... ],
"ordered": <boolean>
}

Example

{
"insert": "users",
"documents": [
{ "_id": 1, "user": "abc123", status: "A" }
]
}

Delete Query

Syntax

{
"delete": <collection>,
"deletes": [
{
"q" : <query>,
"limit" : <integer>
}
]
}

Example

{
"delete": "orders",
"deletes": [ {
"q": { status: "D" },
"limit": 1
} ]
}

Sending Data to Queries

You can read more about sending data from widgets to queries here

Sending data to queries