我正在尝试返回所有收藏的Where字段
grade: 'Grade Two'
,我尝试了许多查询,但得到了错误或什么都没有返回。我只希望我的查询返回来自集合的文档
'Grade Two'
,应该只返回两个文档。
我试过以下问题:
db.users.find({grade: "Grade Two"})
db.users.find({}, {grade: "Grade Two"})
db.users.find({}, {profile: {grade: "Grade Two"}})
我收到错误消息:
"errmsg" : "Unsupported projection option: profile: { grade: \"Grade Two\" }",
{
{
"_id": "4YH8hDjNhN39CTtZh",
"username": "philcee.philips",
"emails": [
{
"address": "ph@gmail.com",
"verified": false
}
],
"profile": {
"name": {
"firstname": "Philcee",
"lastname": "Philips"
},
"gender": "Female",
"nationality": "foo",
"grade": "Grade Two"
},
"roles": {
"__global_roles__": [
"student"
]
},
{
"_id": "8UH8hDjNhN39CTtm6",
"username": "gibson.wilson",
"emails": [
{
"address": "wil@gmail.com",
"verified": false
}
],
"profile": {
"name": {
"firstname": "Gibson",
"lastname": "Wilson"
},
"gender": "Male",
"nationality": "bar",
"grade": "Grade Two"
},
"roles": {
"__global_roles__": [
"student"
]
},
{
"_id": "i7G8hDjKhN39CTYt9",
"username": "daniel.jones",
"emails": [
{
"address": "jones@gmail.com",
"verified": false
}
],
"profile": {
"name": {
"firstname": "Daniel",
"lastname": "Jones"
},
"gender": "Male",
"nationality": "bar",
"grade": "Grade One"
},
"roles": {
"__global_roles__": [
"student"
]
}
}
是否有其他方法从上述集合中查询特定文档?