Skip to main content
MongoDB logo

MongoDB

Overview

Connect Superblocks to MongoDB to build apps with read and write access to a MongoDB instance:

  • Read data from MongoDB and utilize it in API steps or UI components

Read data from a MongoDB and use it within an Application

  • Save information retrieved by other API steps or UI components by writing data to a database

Write data into a MongoDB in a backend API

Setting up MongoDB

1. Add integration

Select MongoDB from the integrations page.

2. Configure settings

Fill out the form with the following settings:

SettingRequiredDescription
NameTRUEName that will be displayed to users when selecting this integration in Superblocks
Connection URITRUEConnection URI used to connect to a MongoDB instance. See Connection URI Docs for standard format.
Database NameTRUEName of database to connect to

3. Test and save

Click Test Connection to check that Superblocks can connect to the data source.

info

If using Superblocks Cloud, add these Superblocks IPs to your allowlist (not necessary for On-Premise-Agent).

After connecting successfully, click Create to save the integration.

4. Set profiles

Optionally, configure different profiles for separate development environments.

success

MongoDB connected Now you can use MongoDB in any Application, Workflow, or Scheduled Job.

Creating MongoDB steps

Connect to your MongoDB integration from Superblocks by creating steps in Application APIs, Workflows, and Scheduled Jobs. Depending on the permissions of the database user configured in the integration (read only, read/write, write only), you can configure a Superblocks MongoDB step to read from and/or write to a database. To get started, enter your query into the text area of the MongoDB step. Then click "Run" to see the Result and Executed Operation below.

See the results and executed operation of a MongoDB step

Query syntax examples

The MongoDB integration supports the MongoDB Extended JSON (v2) query syntax. Here are some examples on referencing certain data types:

Data typeSyntaxExample
Object ID{"FIELD_NAME":{"$oid":"VALUE"}}{"_id":{"$oid":"{{Dropdown1.selectedOptionValue[0]}}"}}
Date{"FIELD_NAME": {"$date": {"$numberLong": "TIMESTAMP_IN_MILLISECONDS"}}}{"createdAt": {"$date": {"$numberLong": "{{moment.now()}}"}}} (to use moment.now() to generate the epoch timestamp)

Use cases

Applications

Visualize data from MongoDB in UI components like charts, tables, and grids.

Visualize MongoDB data in applications using a grid component

Workflows

Enrich customer order data with sales data from MongoDB combined with data from other sources, like Snowflake.

Use a workflow to enrich MongoDB data with data from other datastores like Snowflake

Scheduled Jobs

Send out a daily report via email of the latest sales data.

Use a scheduled job to query MongoDB and send out a daily report

Troubleshooting

Check out our guide on common errors across database integrations, in addition to common MongoDB connection issues. If you are encountering an error that you don't see in the guide, or the provided steps are insufficient to resolve the error, please contact us at help@superblocks.com.