What is the difference between hasMany and referenceMany in the Strongloop loop

I read that embedsMany (in the case of non-relational db) places embedded models in the parent model document. While hasMany creates a new collection of the child model and creates a relationship between the parent collection and the child collection. What about referencesMany ?

There is also this sample project where customer referencesMany Account and hasMany Order . I do not understand the difference.

+5
source share
1 answer

embedsMany : puts all the child data (naturally, and the relation) into itself. each child does not have an identifier and cannot be reused on other lines). he needs only one collection for the child and parent models.

referencesMany : puts only the id of the child relation (reference id) into the model and puts the data in the child model (there is no need to store the identifier of the parent model in the child model, and the identifier of the child model can be reused for other models). he needs the actual two collections for the parent and child model.

hasMany : puts the child data and the parent identifier in the child model. he also needs a real two collection;

+6
source

Source: https://habr.com/ru/post/1243386/


All Articles