This reason this isn't returning any docs, is that orConditionCreator
is returning a JSON string, not an object.
But like I mentioned in the comments, you should be using $in
for this instead:
//tags[0] = "harry" , tags[1] = "potter"
var regexps = tags.map(function(tag) {
// When building regular expressions from strings, use the constructor.
return new RegExp(tag, "i");
});
mongo.peopleColl.find({name: {$in: regexps}}).toArray(function(err, documents) {
if(err) { /* handle */ }
// do stuff with documents
});