I am trying to figure out how to do nested OR/AND where queries like what you would do in MySQL
Take for example
SELECT
first_name,
id
FROM
The query in MongoDB looks like:
Database.collection_name.find(
// This is the condition
{
$and: [
{
$or: [
{province: 'nb'},
{province: 'on'}
]
},
{
city: "toronto"
},
{
first_name: "steven"
}
]
},
// Specify the fields that you need
{
first_name: 1,
_id: 1
}
)
Documentation for $and $or
Some examples and the official documentation for MongoDB find here.