I\'m pretty confused with the use of the select
method. This is how I use it, and it\'s wrong:
Transaction.find({username : user.username}).sele
Now there is a shorter way of doing this (not using .select
and not using an array), just passing the fields separate by spaces as the second argument
User.find({}, 'first last', function (err, usr) {
//Got the result, saved a few bytes of code
});
The Docs
This was pretty helpful: How to protect the password field in Mongoose/MongoDB so it won't return in a query when I populate collections?
Looks like you have a few options.
1) Use select('-_id')
.
2) Use find({whatever: values}, '-_id', callback...}
. I can't verify this method, but if it works with select()
, I don't see why it wouldn't work here.
this is another way: queries in mongoose
Transaction.find({username : user.username})
.select('uniqueId confirmation_link item_name timeout username')
.exec(function(err, txs) {
console.log(txs);
});