Sunday 21 May 2017

Mongoose return some fields from findOneAndUpdate

Using Mongoose in Nodejs you can return some fields using find. eg.

User.findOne({_id:'132324'}, {first_name:1, last_name:1}).exec...

but I can't seem to figure out how to return certain fields using findOneAndUpdate.

User.findOneAndUpdate({_id:'132324'}, {$set : {..bla bla}}, {first_name:1, last_name:1}).exec....

Has anyone achieved this before? I can't find it in the documentation.



via Emad Said

No comments:

Post a Comment