I am a newbie to MongoDB.
I wanted to know if something like this can be achieved?
users Collection :
[
{
name : "John",
Gender : "Male",
},
{
name : "Alex",
Gender : "Male",
},
{
name : "Eva",
Gender : "Female",
}
]
db.users.find({Gender : "Male"});
Response :
[
{
name : "John",
Gender : "Male",
isMatchingQuery : true,
},
{
name : "Alex",
Gender : "Male",
isMatchingQuery : true,
},
{
name : "Eva",
Gender : "Female",
isMatchingQuery : false,
}
]
Can we get something like this where every document is return in response but the ones satisfying the query has a key added with value true and others not satisfying as false. Is it possible through aggregate?