MongoDB
Last updated
Last updated
This is the official documentation of the @forestadmin/agent
Node.js agent.
The MongoDB data source allows importing collections from a MongoDB datasource, without the need for an ORM like Mongoose
To make everything work as expected, you need to install the package @forestadmin/datasource-mongo
.
then, you can declare your datasource like so:
Unlike other (SQL or ORM) datasources, MongoDB does not necessarily have a defined schema structuring the data. Therefore, at startup the agent analyses a sample of documents that live in your database to determine its structure. This process is called introspection. You are able to control how many samples are taken from your database to perform the introspection
Settings those values too high might make your agent slower to startup
If the introspection returns some collections that you do not want to see, you may use the same syntax as for all the other datasources to remove them:
MongoDB stores its data as BSON documents which can be nested. This format looks great on Forest Admin by default, with correct indentation, but you might also want to flatten it into dedicated rows to improve the presentation.
example in manual mode:
The datasource-mongo
uses the same flattening options as the Forest Admin Mongoose datasource, which means that you can control how your nested models should be flattened using