Anda dapat membangun objek kueri Anda secara terprogram, berdasarkan pilihan. Misalnya:
var selections = [0, 1];
var query = { $or: [] };
for (var i=0; i<selections.length; i++) {
var selection = selections[i];
query.$or.push({
Category: Books.CatSelect[selection],
Pages: { $gte: Books.MinPages[selection] }
});
}
MyCollection.find(query).exec(function(err, result){
//...
}