Certain information in this article may be missing or out of date. We are in the process of updating the content.
Connecting to MongoDB
To connect to a MongoDB account, follow the general instructions for connecting most databases.
Data Warehouse
MongoDB is on the Grow Data Warehouse, which we highly recommend you use. For more information about warehousing your data, visit the Data Warehouse Help Article.
Tables
The list of tables available will depend on your unique MongoDB project. You can expect to see one table per dataset associated with the project ID in your connection.
Other Tables
The following tables are available in Grow.
Note that other tables are not automatically turned on and must be toggled on individually for these tables to be stored.
- Other
Custom Tables
- Custom
Warehousing Your Data
-
In the Connections Overview Page, click on your MongoDB connection.
This opens the Connection Details page. - Select the Manage Connection button inside the Connection Details section to open the warehouse table selection flow.
- Select the data you want stored in the Data Warehouse and click the Sync & Store button at the bottom of the Manage Connection page.
This begins the initial population of your warehouse with the tables you defined. Populating your data warehouse for the first time may take a while, sometimes up to several hours.
You may continue working within the app while your data is In Queue or Processing.
If your data source is not already connected, refer to the Connecting to a Data Source for more details.
Sync Interval
Full Sync
Full sync intervals is 12 hours for Custom Tables and Other Tables.
Incremental Sync
Incremental sync is not supported for Custom Tables and Other Tables.
To learn more about sync intervals and how to adjust the default settings, please visit the Sync section of the Data Warehouse help article.
Direct Query
Queries honor the aggregation pipeline
Your Mongo queries honor the aggregation pipeline. You can find more info about the pipeline here. For example, the $match
and $sort
pipeline operators can take advantage of an index when they occur at the beginning of the pipeline. Here are some examples of aggregation provided by Mongo.
Limiting the Data by Specifying a Date Range
If you want to only bring in a certain amount of data form your database (for example, the last 6 months), then you can do that with the following code:
"$dateFromString": {
"dateString": "{{date('-6months','YYYY-MM-DD')}}"
This will only work for v3.6 and above.
You can change this code {date('-6months','YYYY-MM-DD')}
to dynamically select how far back the data should go. Learn more about the options for selecting the dates, read our article on using the date interpolator.
Here's another example of building a simple query that pulls the data from the last 7 days:
[
{
"$match": {
"$expr": {
"$gt": [
"$sold",
{
"$dateFromString": {
"dateString": "{{date('-7days','YYYY-MM-DD')}}"
}
}
]
}
}
}
]
You can read more about using $dateFromString
in MongoDV's documentation.
Rules and How to Query
This article assumes you have some knowledge of MongoDB and JSON and are comfortable writing queries.
Key notes: Anything written in the query needs to be valid JSON. This includes key names, helper functions, aggregation and operators etc.
Any valid query will work, as long as it is valid JSON. Notice that an empty query is still valid JSON.
When you make a query, it needs to be valid JSON. In this example winner should be wrapped in double quotes. {"winner": "Fox"}
When using the find method, up to 10,000 records will be returned if the where clause is empty.
Everything written in the query on the find method (or any method) needs to be valid JSON, which includes wrapping every key in double quotes.
Even help functions like $gt
need to be wrapped in double quotes to make them valid JSON. Numbers and booleans do not need to be wrapped since they are still valid JSON unwrapped.
The $or
operator needs to be wrapped in double quotes as well.
Aggregation functions follow the same pattern, and need to be wrapped in double quotes.
FAQs + Tips and Tricks
How can I make sure my data is secure?
We have several items in place to keep your data safe. Check out our security article to see what steps you can take to keep control of your data.