开发者

Choosing between embeds_many and references_many in Mongoid

开发者 https://www.devze.com 2023-02-11 08:30 出处:网络
what are the key points that one should think of while choosing betwee开发者_开发问答n embeds_many and references_many (or embeds_one and references_one) in Mongoid?

what are the key points that one should think of while choosing betwee开发者_开发问答n embeds_many and references_many (or embeds_one and references_one) in Mongoid?

I'm currently preferring embeds_many over references_many, but that is resulting in too many nested embeds_many'ies and I'm worried that it might add unnecessary overhead to the database.


The most important thing to be aware of is the 4 MB limit for each document in MongoDB - by using references instead of embedding documents, you can keep the size of your documents lower.

Other information about the differences can be found here.


I think that you should to use "entity-object" and "object-value" definitions from DDD. For entity use reference,but for "object-value" use embed document.

And check this question for more details about entity vs object-value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号