Skip to content

Instantly share code, notes, and snippets.

@wethinkagile
Last active August 29, 2015 14:06
Show Gist options
  • Save wethinkagile/3328f95f6caf4257943a to your computer and use it in GitHub Desktop.
Save wethinkagile/3328f95f6caf4257943a to your computer and use it in GitHub Desktop.
Mongoose Query with Selectors
/*
items = {
oranges: 'Navel',
apples: 'Braeburn',
grapes: 'Vroege van der Laan'
}
*/
app.get('/items', findFunc);
findFunc = function(req, res) {
var myQuery = itemsModel.find();
myQuery.select('-apples');
myQuery.exec(function (err, items) {
if (!err) {
return res.send(items);
} else {
return res.send({ status: '500 Server error' });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment