设计 MongoDB 模型?
我有一个关于在 mongo db 中设计数据模型的概念性问题。 我有一些“列表”的记录。每个列表都是“一行”记录,包含 id、descr、createdBy 等字段。但现在我有一个要求,每个“列表”都可以与其他用户共享。当用户登录查看他创建的“列表”和与他共享的“列表”时,设计/重新设计模型的最佳方法是什么?我正在考虑创建新字段“sharedWith”,其中共享“list”的所有用户名都用逗号(或其他内容)分隔。然后当请求在此字段中搜索时。但不知何故,这种方法在我看来并不是很有用。您能给我一些建议或指导吗? 我正在使用带有猫鼬的nodejs。
谢谢!
i have one conceptual question about designing data model in mongo db.
I have some record for "lists". Each list is "one row" record with id, descr, createdBy etc. fiels. But now i have a requirement that each "list" can be shared with other users. What is the best way to design/re-design the model so when user login to see "lists" that he created and "lists" that was shared with him? I was thinking of creating new field "sharedWith" in which all usernames with which "list" is shared to be put separated with comma(or something else). And then when request is made to search in this field. But somehow this approach doesn't seem to me very useful. Can you give me some advice or guidelines ?
I'm using nodejs with mongoose.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这似乎是一个明智的设计。
That would seem a sensible design to me.