Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between embedsMany and hasMany in Strongloop loopback

At first sight they seem to do the same thing: define a one-to-many relation So why would you choose one or another?

like image 540
Ernie Avatar asked Jun 11 '15 14:06

Ernie


1 Answers

EmbedsMany - a model that embeds many instances of another model; for example, a Customer can have multiple email addresses and each email address is a complex object that contains label and address. A hasMany relation builds a one-to-many connection with another model.

EmbedsMany embeds all child objects in the same parent object, HasMany stores child objects separately and has a property as the foreign key to reference the declaring model.

like image 162
snathan Avatar answered Sep 21 '22 19:09

snathan