I want to have a limit on each field itself when using collection.find(). In below example I can place a limit as a method for find, but how to perform it on each field accordingly. Is this available in mongodb?
var collection = db.collection('collAutocomplete');
collection.find({
$or: [{
"Town": new RegExp(searchKey, 'i') //Can I put a limit here?
}, {
"State": new RegExp(searchKey, 'i') //Can I put a limit here?
}, {
"Nation": new RegExp(searchKey, 'i') //Can I put a limit here?
}]
}).limit(3) //I can put a limit here..
.toArray()function(err, item) { }});