[英]MongoDB large array or documents
We are trying to save profile views.我们正在努力保存个人资料视图。
We created a schema something like that我们创建了一个类似这样的模式
{
user: userId,
viewers: []
}
We think the viewers array could have millions of items我们认为 viewers 数组可能有数百万个项目
So would it make more sense to do it this way?那么这样做会更有意义吗?
{
user: userId,
viewer: viewerId
},
{
user: userId,
viewer: viewerId
},
{
user: userId,
viewer: viewerId
}
In this way this collection could have millions of documents这样这个集合可能有数百万个文档
What is the best way to handling this处理此问题的最佳方法是什么
I think this would be better, it's way more easy to analyze data.我认为这样会更好,分析数据更容易。 And will not cause the limit of 16mb in one document.并且不会造成一个文件16mb的限制。
{
user: userId,
viewer: viewerId
},
{
user: userId,
viewer: viewerId
},
{
user: userId,
viewer: viewerId
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.