I'm having trouble developing how to embed the multiple depths of a nested schema in MongoDB through Mongoose and node.js.
The example below is a little clever, but hopefully explain my problem. As for why each circuit is defined as a complete model, but not used in the example, it is simply because in my real problem they are relevant, useful models, and I wanted this example to be realistic if it matters.
So, here is an example of defining a circuit in reverse order, i.e. smallest russian doll:
I hope you can say from this that there is a main model, StationeryBox, which has a shortcut and contains two compartments for DrawingTools and MeasuringTools, which are a nested circuit. They, in turn, have their own shortcuts and contain nested schemas for Pens and Rulers. The problem I encountered is a nesting of the 2nd level, i.e. pens / rulers. Thus, based on mongoose documents, creating a top-level model, and clicking on the first nested objects works fine, then the problem hits. For example:
And if I go back one step and try to insert pens at the same time as the drawing tools:
I know this is not a super-realistic example, but it is a simplified example of a real system that I create, and it was the easiest way to illustrate this.
The actual save happens after that, of course, and I left it, but I need to add these next levels in the save callback, maybe?
If someone tells me where I'm wrong, or call me in the right direction, I will buy you a good cake (an imaginary cake, only I am afraid if you do not live next to me).