Skip to content

Instantly share code, notes, and snippets.

@gabrielmiller
Created January 2, 2014 20:04
Show Gist options
  • Save gabrielmiller/8225733 to your computer and use it in GitHub Desktop.
Save gabrielmiller/8225733 to your computer and use it in GitHub Desktop.
API Request Filter Object Variations
// "$and" and "$in"
{ "$and" : [
{ "projob.job.department" :
{ "$in" :
[ "Engineering", "Marketing" ]
}
},
{ "projob.rating" : {
"$in" :
[ 3, 4, 5 ]
}
} ]
}
// "$and" and no "$in"
{ "$and" : [
{
"projob.department" : "Engineering"
},
{
"projob.rating" : 5
}]
}
// no "$and" and "$in"
[
{ "projob.job.department" :
{ "$in" :
[ "Engineering", "Marketing" ]
}
},
{ "projob.rating" : {
"$in" :
[ 3, 4, 5 ]
}
}
]
// no "$and" and no "$in"
[
{
"projob.job.department" : "Engineering"
},
{
"projob.rating" : 5
}
]
@dxa59
Copy link

dxa59 commented Jan 2, 2014

#1 is good
#2 is technically correct but let's just use $in context for now, since the filters are always a list. This will simplify the back end too.
#3 and #4 are invalid.

@gabrielmiller
Copy link
Author

I'll wrap the fields in every request in an "$and" and the values in "$in" (#1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment