Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

ruby on rails - Difference between embeds_many and has_many in mongoid

Can anyone explain to me the difference between embeds_many and has_many in mongoid?

question from:https://stackoverflow.com/questions/10860116/difference-between-embeds-many-and-has-many-in-mongoid

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

embeds_many is used to store relative documents inside of parent document.

has_many is used to store a relation between documents in separate collections. Relative records of has_many have field that stores id of the parent document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...