Reputation: 25
I have mongoDB "users" collection in JSON format and I want to return all the data having privacy is true. How can I do it ?
{
"name" : "Maria Kari",
"social" : [
{
"facebook" : "www.fb.com/maria.mongodb",
"privacy" : true
},
{
"twitter" : "www.tw.com/mongodb",
"privacy" : false
}
],
"personal" : [
{
"cell_no" : "+1-99082198414",
"privacy" : true
},
{
"email" : "[email protected]",
"privacy" : false
}
]
}
Here, I want to return the data having privacy is true. For example, facebook, it has privacy is equal to true. How to build query for this ?
Thank You. :')
Upvotes: 0
Views: 3573
Reputation: 1050
db.users.find( {
$or:[{ 'social.privacy': true },{'personal.privacy': true}]
)
Upvotes: 1