我开始将 MongoDB 用于一个新项目,并希望使用以下方案将客户数据插入其中:
{
admin: {mail: "", realName: {first: "", last: ""}, address: {street: "", city: "", state: ""}, payment: {type: "", blz: "", account: ""}},
users: [
{mail: "", password: "", realName: {first: "", last: ""}},
...
],
categories: [
{name: "", assignedUsers: [{ID: "", readOnly: true}, ...], entries: [
{name: "", tags: "", site: "", user: "", pass: "", notes: ""}
],
...
]
}
但是,我发现不容易,例如,通过邮件地址获取“用户”数组中的用户之一,或者获取一个用户通过其 ID 分配到的所有类别。
所以看起来我必须将我的分层数据分成多个集合,但我不确定最好的方法是什么。你会建议我如何拆分这些数据?