After extracting and parsing a querystring from a URL, I am able to map it into an object structure like this:
{ '$and': [ { length: { '$gt': '2' } }, { length: { '$lt': '55555' } } ] }
This object is stored in a constant called q.
Now, if we were to construct a Mongoose find query based on the mapped object, it might look something like this:
Schema.find(q, function (err, results) {
if (err) {
console.log(err);
}
else {
console.log(results);
}
});
However, the above code returns empty lists ([]). When logging q to the console, the following output is displayed:
{ '$and': [ { length: [Object] }, { length: [Object] } ] }