These are chat archives for Automattic/mongoose

Sep 2015
Erinç Fırtına
Sep 30 2015 13:33
what is the best way to do extend mongoose model?? I have a vehicle model and I want to extend Car and Truck models from Vehicle model. I checked discriminator but I wanted to ask here too, maybe someone has better apparoach.
Sep 30 2015 16:47
Hey guys, can anyone tell me the option to exclude a field when returning a new document from findOneAndUpdate?
I have the following code and want to exclude the password and __v fields:
User.findOneAndUpdate({_id: userId}, {$push: { _downvotes: message._id }, $pull: { _upvotes: message._id }}, { new: true, without: 'password' },
function(err, user) {
if (!err) {
socket.emit('user_changed', user);
Matthew Bonig
Sep 30 2015 20:23
hey all
Valeri Karpov
Sep 30 2015 21:19
@NateBrady23 set 'projection' option, like User.findOneAndUpdate(query, update, { projection: { password: 0 } });
hi @mbonig what's up
Matthew Bonig
Sep 30 2015 21:44
hey, so... I HAD a question, .. the .populate() is super awesome, but is there any way I can apply it AFTER I've already done some work? I get the query results and then do some mapping, to build up a few things on the object (that populate can't do), but don't want those values exposed to the client, so I can't let .populate() remove them as I need them still. Make sense? So I'm having to do MY work, then manually do what populate was doing for me. not ideal... very flimsy
I got around it. sorta, but would love to still know a solution.. even if it was not using .populate directly, but something like it.