[英]Meteor CRUD many-to-many relationships MongoDB
I have 3 collections interconnected through many-to-many relationships. 我有3个馆藏通过多对多关系相互联系。 Therefore, I have 2 concerns:
因此,我有两个问题:
For most scenarios, I'd probably have the referencing IDs on each of the objects, like this: 对于大多数情况,我可能在每个对象上都有引用ID,如下所示:
{
"_id": "123",
"firstReferenceCollectionId": "abc",
"secondReferenceCollectionId": "def"
}
If your application is going to have massive scale, I'd probably further denormalize the data based on how it's actually being used. 如果您的应用程序要大规模发展,我可能会根据数据的实际使用情况进一步对数据进行非规范化。
To answer your second question, you really shouldn't need to worry about that with the above approach, since the internal id of the reference won't change when other properties on those objects change. 要回答您的第二个问题,您真的不需要担心使用上述方法,因为当这些对象上的其他属性更改时,引用的内部ID不会更改。 If you go the route of additional denormalization, use
meteor add matb33:collection-hooks
to sync up data on upserts. 如果您采用额外的非规范化路线,请使用
meteor add matb33:collection-hooks
来同步upserts上的数据。 Here's the documentation link: https://github.com/matb33/meteor-collection-hooks 这是文档链接: https : //github.com/matb33/meteor-collection-hooks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.