Skip to main content

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

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

Setting up MongoDB

1. Select MongoDB from the in-app integrations page

Select MongoDB from the in-app Integrations page and fill out the form with the following configuration:

  • Display Name - Name that will be displayed to users when selecting this integration in Superblocks
  • Connection URI - Connection URI used to connect to a MongoDB deployment. Format: mongodb+srv://<username>:<password>@<host>/?retryWrites=true&w=majority Connection URI Docs
  • Database Name - Name of database to connect to

2. Fill out the form and click "Create Integration"

info

Add Superblocks IPs to your allowlist if using Superblocks Cloud (not necessary for On-Premise-Agent)

3. Set environments

After creating the integration, you can optionally set different connection settings for your Production and Staging environments. Be sure to click Test Connection for each environment.

success

MongoDB Connected You can now write SQL to read from and write to 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 SQL statement below.

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.

Workflows

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

Scheduled Jobs

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

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@superblockshq.com.