Querying MongoDB

The following document assumes that you understand the basics of connecting to databases on Appsmith. If not, please go over them before reading further.

The mongo database command syntax is slightly different from the mongo collection methods you may be familiar with. Read more

All mongo queries return an array of objects where each object is a mongo document and properties of the object are the keys of the document.

Appsmith provides template queries to help with the syntax

Click to expand

Taking Inputs from Widgets

Queries can take inputs from widgets using the mustache syntax inside the query {{ searchInput.text }} where searchInput is the name of the widget and text is the property of the widget.

You may need to wrap your string mustache bindings in quotes to make your query a valid JSON

"find": "users",
"filter": {
"role": "{{statusDropdown.selectedOptionValue}}"
"limit": 10
Click to expand

Displaying Query Data

Query data can be displayed in a table or chart using the mustache syntax {{ queryName.data }} . You can read more about displaying query data below.

The widgets are automatically refreshed when the data is changed