I have a code which requires me to get user details from a mongo database collection
Following is one of the field in my Users collection
"emailSettings" : {
"flag1" : true,
"flag2" : true,
"flag3" : true,
},
I'm parsing the Mongo collection from my java program using the BasicDB
object and I would want to get all the entries which satisfy the emailSettings.flag1 =true
and emailSettings.flag2 = true
.
When I use BasicDBObject
to do this, I'm able to get entries satisfying only one of the conditions.
Is there a solution for this ?
In Mongo query parts are combined with 'and' operator by default. So simply doing this
should give you expected result.