I've a mongodb collection which has more than 20 million collection.
db.collection.find({ 'attr.type': new RegExp('automotive snow' 'i') }).limit(10);
Above mongo shell query returns the results as expected, But implementing the same in a node.js application it doesn't seem to work right. I can't really figure out the reason.
Sample node.js code
db.collection.find({ 'attr.type': new RegExp('automotive snow' 'i') }, function(err, docs) {
console.log(docs); // returns undefined
});
I use mongojs
module, Tried native mongodb
module as well but the results seemed to be the same hence decided to use mongojs
module.
Does anyone know what the issue is?