【发布时间】:2013-07-13 04:42:21
【问题描述】:
我将在 mongodb 中创建一个收件箱结构。对于多用户消息,我在收件箱架构上遇到了一些问题。 我想创建这样的东西,其中收件人包含对象。每个对象都包含 userId 和一个日志,以了解消息是否为红色。 如果它是一个正确(高效!!)的结构,用户 456 如何知道他是否有一些消息要阅读?
{
userId: "123"
,recipients: [ {userId:123, read:true}
,{userId:456, read:false}
,{userId:789, read:false} ]
,text: "message wrote by user 123"
}
,{
userId: "456"
,recipients: [ {userId:123, read:false}
,{userId:456, read:true}
,{userId:789, read:false} ]
,text: "message wrote by user 456"
}
【问题讨论】:
-
更多信息:在本例中,用户 123 写了第一条消息,而用户 456 和 789 没有阅读。之后,用户 456 向相同的用户(123 和 789)写了一条新消息,而用户 123 和 789 没有阅读它。
标签: mongodb data-structures mongoose database