您将如何在 MongoDB 中为电子邮件应用程序建模?
如何在 MongoDB 中对电子邮件应用程序(如 gmail)进行建模?您会为对话
建模吗? 收件箱
/ 发件箱
?或邮件
?
谢谢
How would you model an email app (like gmail) in MongoDB? Would you model a Conversation
? Inbox
/ OutBox
? or mail
?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Gmail 使用标签的概念(如 stackoverflow 上的标签)。这意味着收件箱、发送邮件、加星标等普通的电子邮件对象,只是用指定的标签标记。因此,只有
Email
和Labels
。您可以使用 Gmail 中的搜索来查看它,例如
label:inbox
或label:Starred
。我想建议一个相当简单的设计,如下所示:
当然我错过了一些东西,但我想从上面的模式开始并在将来如果需要的话添加更多功能是可以的。
更新:
对于“对话视图”,我猜所有回复都会显示到嵌套集合
Replies
(我已经更新了我的架构)。逻辑如下:一旦您收到新消息,您需要检查是否已存在同名电子邮件(当然需要删除“Re”等),还需要检查收件人列表中已发送电子邮件的用户。如果上述条件成立,则只需将新电子邮件添加到
Replies
的嵌套集合中,否则添加到电子邮件集合中。Gmail use concept of labels (like tags on stackoverflow). That mean that inbox, send mail, starred, etc normal Email object, just marked with specified label. So, there are only
Email
andLabels
.You can see it using search in gmail like
label:inbox
orlabel:Starred
.I'd like to suggest a fairly simple design like this:
For sure i've missed something, but i guess it's okay to start from above schema and add more features in future if neeed.
Update:
For the 'Conversation View' i guess all replies show go to the nested collection
Replies
(i've update my schema). Logic is following:Once you have received a new message you need check if email with same name already exists (for sure need to Remove 'Re', etc..) also need to check that user that has sent email in list of recipients. If above conditions is true then just add new email to nested collection of
Replies
otherwise add to collection of emails.