I'm trying to return the saved object as the request response, but I don't want whole object returned by Model.save()
function, it's returning more information than I want, like _id
, __v
.
My request code is like this:
function insertUser(req, res) {
const userName = req.Body.name;
User.save({ name : userName })
.then(r => {
res.send(r);
});
}
It's returning fallowing JSON
to me:
{
_id: 590f529976aa6142d91870b7,
name: 'blablabla'
__v: 4
}
How can I set it to return only { name : 'blablabla' }
?
via Lai32290
No comments:
Post a Comment