我在 MongoDB 中有两个集合
用户(查找()):
{ "_id" : ObjectId("5021314e372c50859ced7063"), "name" : "Vinícius", "username" : "vinixhenri", "password" : "vinix123" }
{ "_id" : ObjectId("50213180372c50859ced7064"), "name" : "André", "username" : "andre", "password" : "andre123" }
和项目(findOne()):
{
"_id" : ObjectId("50215d09ddf7410905000000"),
"name" : "Projeto X",
"local" : "/home/server/compartilhamento/htdocs/project_x/",
"permissions" : [
{
"user" : "5021314e372c50859ced7063",
"alter" : true,
"view" : true,
"delete" : true,
"view_task" : true,
"insert_task" : true,
"alter_task" : true,
"delete_task" : true
},
{
"user" : "50213180372c50859ced7064",
"alter" : true,
"view" : true,
"delete" : false,
"view_task" : false,
"insert_task" : false,
"alter_task" : false,
"delete_task" : false
}
],
"tasks" : [
{
"responsible" : "5021314e372c50859ced7063",
"description" : "Ajuste na barra lateral do site"
},
{
"responsible" : "5021314e372c50859ced7063",
"description" : "Ajuste no cabeçalho do site"
},
{
"responsible" : "50213180372c50859ced7064",
"description" : "Ajuste no rodapé do site"
}
]
}
我展示了一个 findOne() 项目集合,但我想知道它怎么会是一个 find() 。
我将如何获得所有收费的用户名为“vinixhenri”的任务?用户标识符是任务->责任。
我还想知道我在保留 _id 用户方面做得对吗?是不是必须先查阅用户信息,然后再从数据库中查询项目信息?或者我应该在集合中复制有关用户任务的信息?