Created
January 2, 2014 20:04
-
-
Save gabrielmiller/8225733 to your computer and use it in GitHub Desktop.
API Request Filter Object Variations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "$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 | |
} | |
] |
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
#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.