I am able to retrieve only selected fields in mongodb using Monk using the below method
collection.find({}, 'Name Age -_id', function (e, docs) {
res.json(docs);
});
This works fine, but i am facing issues when i add one more option in the query it throws fn should be a function
error as it expects third parameter to be success callback function
I get this error when i try
collection.find({},{limit:5}, 'Name Age -_id', function (e, docs) {
res.json(docs);
});
I tried using on success function but still got the same error
collection. find({} , { limit: 5 }, 'Name Age -_id').on('success', function (e, docs) {
res.json(docs);
});