Skip to content

Instantly share code, notes, and snippets.

@nicolaslopezj
Created June 11, 2018 18:45
Show Gist options
  • Save nicolaslopezj/c15e092ca483bdb54eb6d9e6e537427e to your computer and use it in GitHub Desktop.
Save nicolaslopezj/c15e092ca483bdb54eb6d9e6e537427e to your computer and use it in GitHub Desktop.
queries
conditionsgroup
const finalquery = {$or: []}
for (const group of conditionsgroup) {
const groupQueries = {$and: []}
for (const conditions of group) {
const query = { /* generar query */ }
groupQueries.$and.push(query)
}
finalquery.$or.push(groupQueries)
}
{
$or: [
// cada grupo aca
{
$and: [
// cada condicion del group
{growth: {$gte: 10}},
{genre: 'reggaeton'},
]
},
{
$and: [
// cada condicion del group
{genre: 'rock'}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment