MongoDB
MongoDB Datasource Connector Details
Last updated
MongoDB Datasource Connector Details
Last updated
MongoDB is a document database and does not have a direct SQL interface. ChartSQL uses a local SQLite database to convert documents into SQL tables that ChartSQL can use for charting.
See SQLite datasource documentation for working with SQLite's flavor of SQL
Install a MongoDB datasource in ChartSQL studio following the typical datasource instructions
ChartSQL visualizations for MongoDB have a two step process:
Write a MongoDB collection or aggregation pipeline query
Shape the final data with SQL
The ChartSQL Editor has an additional tab, "MongoDB Query" for writing the Mongo collection query
To query a MongoDB colleciton, you will specify a collection
, and a find
structure, which maps to a mongodb.collection.find method call
When find() is executed against the collection, the projected result set will be stored in a local SQLite database for further querying. The name of the table is the same as the collection.
You should not find* an entire collection, because it will necessarily be copied to your local database. Match and limit the items of your collection to just those you need to visualize
The result of find() is transferred to a local SQLite database. You can then query the result with SQL.
Select all records returned from the mongodb find:
If necessary you can further shape the data with SQL:
ChartSQL uses SQLite as the local database to query collections. See the SQLite datasource for syntax to query with.
MongoDB has a new SQL interface. However, as of 1/14/2024 we could not get it to work reliably, and it is not very documented. In the future, we may be able to provide direct support for MongoDB Atlas SQL.