MongoDB Integration

Connecting to MongoDB

Retool supports specifying your MongoDB's credential via connection string as well as normal host, username, password, etc. combination.

If you are using the cloud version of Retool, make sure to whitelist our IP Address


MongoDB Connection String

Retool supports mongodb+srv style connection strings.
A Retool resource corresponds to a single MongoDB database. MongoDB Atlas adds /test as the default database name. Make sure to change that to your database name.

Querying MongoDB

Basic Queries

You can now write MongoDB queries from Retool's editor interface. You first select which collection to edit, the method to query your MongoDB database with, and depending on which method, you can configure the query.

Below is a simple example of querying a MongoDB database for companies where name = 'Uber'


We don't support MongoDB's classic syntax

Instead we support MongoDB's Extended JSON syntax. For more information see

Here's an example of using MongoDB's Extended JSON Syntax to query based on an Objectid

See below for some simple equivalencies from the normal MongoDB syntax and the Extended JSON Syntax. In Retool, use the Extended JSON Syntax.

// Object Ids

{ _id: ObjectId('5b3ddc6dd2ab742125322cf3') } // MongoDB classic syntax
{ _id: { $oid: '5b3ddc6dd2ab742125322cf3' } } // Extended JSON Syntax

// Dates: 
{ createdAt: new Date('2018-08-31T05:26:05+00:00') } // MongoDB classic syntax
{ createdAt: { $date: '2018-08-31T05:26:05+00:00'} } // Extended JSON Syntax

Dynamic Queries

Just like any other datasource in Retool, you can also refer to dynamic variables inside your MongoDB Queries. Here's an example of searching a MongoDB database based on a value of a textinput:


A walkthrough tutorial for working with MongoDB in Retool

If you're working with MongoDB data in Retool, we put together a walkthrough guide to help get your Atlas setup connected and build a sample listing approval tool using Mongo's sample_airbnb dataset. Check it out here!

Updated 9 months ago

MongoDB Integration

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.