Basic usage
Example schema
Here’s an example Mongoose schema with nested data:Flatten modes
The Mongoose datasource offers four transformation strategies:flattenMode: 'auto'
Arrays of objects and references are converted to independent collections. Other nested fields are moved to the root level.
flattenMode: 'none'
No transformations are made. Forest collections use the exact same structure as your Mongoose models.
flattenMode: 'manual'
You are in full control of which virtual collections are created and which fields are moved to the root level.
flattenMode: 'legacy'
Maintains backward compatibility with previous datasource versions.
Data navigation
When working with nested or related data, use specific separators:- Nested fields: Use
@@@to access nested properties - Related data: Use
:to navigate relationships
address:city@@@name accesses the name field within city within the address relation.
Virtual collections
Inauto mode, the datasource may create virtual collections to represent relationships. If you use a collection whitelist, make sure to include these virtual collections in your configuration.
Source code
This connector is open source. Browse the code or contribute on GitHub:@forestadmin/datasource-mongoose.