feature request: nested schemas - fully declarative pojo schema definitions #7494
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Do you want to request a feature or report a bug?
feature
This is very related to #7181 but after starting to write there I decided it's probably off-topic.
TL;DR:
What is the current behavior?
But when it's not an array, it's impossible to do so without:
child: { type: new Schema({...}) }
That means there are certain schemas that can't be fully described with passing a single configuration pojo to Schema() (namely when you need single subdocuments).
"What's the big deal? Just wrap the child in 'new Schema()' and move on", you say?
I share my schema definitions between /packages/client and /packages/server, and I currently can't have just a simple pojo in /packages/shared.
Instead of this:
I have to turn it into a factory of sorts so I can use the right "mongoose" - something like this:
What is the expected behavior?
Making the two equivalent would be great, but I don't think everyone would want it. So if instead, we can have a subSchema: true option or something like that it would be awesome possum.
Please mention your node.js, mongoose and MongoDB version.
The text was updated successfully, but these errors were encountered: