I'm trying to figure out how to generate the following SQL condition using Feather's REST query:
(color = 'blue' OR color = 'green') AND (sport = 'hockey' or sport = 'football')
This is what I've tried (based on the documentation):
?$or[0][color][$eq]=blue&$or[1][color][$eq]=green&$or[2][sport][$eq]=hockey&$or[3][sport][$eq]=football
But this generates the following:
((color = 'blue') OR (color = 'green') OR (sport = 'hockey') or (sport = 'football'))
I've tried different combinations and even nested $or
statements but I cannot seem to wrap my head around it. Is this even possible in FeathersJS? Any suggestions would be greatly appreciated.
You can restructure this using $in
.
// Object
{
color: {
$in: ['blue', 'green']
},
sport: {
$in: ['hockey', 'football']
}
}
// String: ?color[$in][0]=blue&color[$in][1]=green&sport[$in][0]=hockey&sport[$in][1]=football
which generates:
WHERE color IN ('blue', 'green') AND sport IN ('hockey', 'football')