I have a NodeJS server running express with a get method at '/api/jobs/'. When called I get some querystring parameters from the url and they make a query against the MongoDB database to get jobs.
Example Url: '/api/jobs/?Groups=1,2&Statuses=3,4'
The MongoDB query i am trying to construct is this:
{ $or: [{"Group.Id" : 1}, {"Group.Id" : 2}], $or: [{"Status.Id": 3}, {"Status.Id": 4}]}
If I run this directly against the database I get the results I need but I can't think of way of constructing the query dynamically in JavaScript. Any attempt i've made gives me an object like this as the $or property can only exist once in a proper JSON object.
{$or : [{"Group.Id" : 1}, {"Group.Id" : 2}]}
Any ideas on how to do this either using JavaScript or thorugh the MongoDB Node API?