This is my sample documents in DB.
{
"_id":1,
"object":{
"featureOne":true,
"featureTwo":false,
"featureThree":false,
"featureFour":false
}
}, {
"_id":2,
"object":{
"featureOne":false,
"featureTwo":false,
"featureThree":false,
"featureFour":false
}
}, {
"_id":3,
"object":{
"featureOne":true,
"featureTwo":false,
"featureThree":false,
"featureFour":false
}
}
I want to get one object with "featureOne": true and another with "featureOne": false in a single query. I have knowledge on finding data using a particular key and value. But how can I get the data using same key of true and false values in a single query. Present I am using this code
db.collection(collectionName).find({"featureOne":true, {limit:1}).toArray(function(err, results) {
db.collection(collectionName).find("featureOne":,false{limit:2}).toArray(function(err,res {
console.log(results,res);
});
});
Is there any better way to achieve this?