Created
November 3, 2019 21:47
-
-
Save chewtoys/076c7ce2426a0d4d3969a0601dc34f5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const { | |
| omit, | |
| } = require('lodash') | |
| transform() { | |
| const transformed = {} | |
| const fields = ['id', 'name', 'stats'] | |
| fields.forEach((field) => { | |
| transformed[field] = this[field] | |
| }) | |
| return transformed | |
| } | |
| const omitS = req.body.stats | |
| const updatedS = omit(req.body, omitS) | |
| updatedS.save() | |
| .then(savedS => res.json(savedS.transform())) | |
| .catch(e => next(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment