V
V
Vitaly Stolyarov2017-12-23 17:43:28
NoSQL
Vitaly Stolyarov, 2017-12-23 17:43:28

How will MongoDB store a model nested within another model?

Considering the example from this question.
There is a separate model for Roleand 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

1 answer(s)
L
longclaps, 2017-12-23
@Ni55aN

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 question

Ask a Question

731 491 924 answers to any question