.toObject({flattenMaps: true}) on parent requires explicitly setting flattenMaps: true on child documents nested in maps #10653
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
When calling
.toObject({flattenMaps: true})
on a parent document, maps of child documents are not flattened, unless one explicitly setschildSchema.set('toObject', { flattenMaps: true });
on every child schema.If the current behavior is a bug, please provide the steps to reproduce.
Output:
What is the expected behavior?
If I call
.toObject({flattenMaps: true})
on a parent document, I would expect not to have to explicitly set flattenMaps: true on all child schemas which are part of maps in order to flatten them.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 6.0.3
Node v14.17.6
The text was updated successfully, but these errors were encountered: