Mongoid Relationships

1:1 embedded relationship: 

 

M:1 linked relationship(one_direction): 

child uses belongs_to 

parent uses has_many 

 

1:M embedded relationship: 

 

M:1 embedded relationship:

 

 

*annotated link 

*"1" side has a primary key and typically has no reference to the child within the document 

*"M" side will typically host the foreign key

 

1:1 Linked relationship - has_one:

child belongs_to 

parents has_one 

 

M:M Linked Relationship 

has_and_belongs_to_many 

 

posted @ 2019-04-30 11:04  vixennn  Views(124)  Comments(0)    收藏  举报