Skip to content

Create Datasets with MongoDB

Flowtrail AI allows you to create datasets from MongoDB, offering flexibility to use either MongoQuery or direct SQL queries. This integration enables you to leverage MongoDB’s NoSQL capabilities and create robust datasets tailored to your needs

How to Create a Dataset with MongoDB

Learn how to create datasets from MongoDB using either MongoQuery or direct SQL queries. This section guides you through entering and executing queries, saving datasets, and adding parameters for dynamic data management.

Choose Query Type

After selecting your MongoDB datasource, choose between MongoQuery for MongoDB-specific queries or Direct SQL Query for SQL-based queries.

choose-mongo-query-type

  • MongoQuery: Use MongoQuery to write and execute queries tailored to MongoDB’s NoSQL structure.
  • Direct SQL Query: Alternatively, use direct SQL queries. Note that direct SQL queries have limitations and should be used according to the MongoDB documentation for proper syntax and functionality.

Enter and Execute Query

Write your query in the editor based on your selected query option. Use the appropriate syntax and functions for MongoQuery or Direct SQL Query, and then execute it to view the results. mongo-query

Save Dataset

After executing your query, you can save the dataset. Choose a folder if needed to organize your datasets effectively

Add Parameters

Datasets with parameters in Flowtrail AI enable you to create dynamic queries that can adapt to varying criteria, enhancing flexibility and precision in data retrieval. Configure parameters such as string, number, boolean, date, select, multiselect, and SQL query to tailor your dataset queries to specific needs. Each parameter can be customized with variable names, default values (if needed), and optional requirements. To add parameter in your query click on add parameter button from dataset page. mongodb-parameter

Parameter Configuration

For comprehensive guidance on configuring parameters in your queries, please visit the Parameter Configuration. page. This resource provides detailed instructions on setting up and managing different types of parameters to enhance your dataset queries.

Example Scenario: Fetching Workspaces within a Date Range

To demonstrate parameter usage, let’s create a dataset to fetch a list of workspaces created within a specific date range. Here’s the sample query to fetch the workspaces within a specific date range.

example.js
db.Workspace.find(
{
createdAt: {
$gte: new Date('{{startDate}}'),
$lte: new Date('{{endDate}}'),
},
},
{ name: 1, _id: 0 }
).toArray()
  • ”startDate” and “endDate” are parameters that allow you to dynamically filter workspaces based on their creation date.

By using parameters, you can customize your datasets to reflect the data range you’re interested in, providing more flexibility and control over your MongoDB data.

Troubleshooting and Additional Help

If you have more questions about the parameters or encounter any issues, please join our Discord channel or Email us for support.