Last active
August 29, 2015 14:06
-
-
Save wethinkagile/3328f95f6caf4257943a to your computer and use it in GitHub Desktop.
Mongoose Query with Selectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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