Answer the question
In order to leave comments, you need to log in
How will MongoDB store a model nested within another model?
Considering the example from this question.
There is a separate model for Role
and User
, but at the same time, a field of type is used in User.
When saving a Role independently, and then when saving a User with one of whose fields is the previously saved Role object, how will it be represented in memory? The field from User will simply refer to the Role object, or will a copy be created? mongoose.model('Role').schema
Answer the question
In order to leave comments, you need to log in
MongoDB will store the model in no way. This crap is on the conscience of the authors of mongoose.
MongoDB will store documents.
It is important.
MongoDB is a schemaless database.
It does not support referential integrity in any way - everything is only by hand.
The User.Role field will be a copy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question