Assume one document in student
collection as follows:
{
_id:{
time: 1
loc: 'A'
},
name: 'Jery'
}
I want to filter _id.time
, like so:
db.student.find({}, {'_id.time':1})
But I got a result:
{
_id:{
time: 1
loc: 'A'
}
}
Why the result is not as follows:
{
_id:{
time: 1
}
}
So, where is my error? And how to write the query operation.
Thank you.
Just tried a few things but it seems to be a limitation:
You can however easily achieve this with an aggregation query with a
$project
stage.