Is it possible to build queries dynamically? For instance, I need to build a function like this:
var dynamicQuery = function(collectionName) {
return collectionName.find({});
}
Is it possible to build queries dynamically? For instance, I need to build a function like this:
var dynamicQuery = function(collectionName) {
return collectionName.find({});
}
You have two options:
pass the collection itself
pass the name of the collection
Recommended reading: collections by reference.