Created
May 31, 2018 22:16
-
-
Save basekays/5d8234e62cfaca948c41969016f48acd to your computer and use it in GitHub Desktop.
handler.js
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
| export default (req, res) => { | |
| const { | |
| WishlistPlaces, | |
| } = req.app.models; | |
| const placeId = req.body.placeId; | |
| console.log('******************************************'); | |
| console.log(placeId); | |
| WishlistPlaces.findOrCreate({ | |
| where: { userId: 1}, | |
| defaults: { | |
| placeId: placeId | |
| } | |
| }) | |
| .spread((wishlist_places, created) => { | |
| console.log(wishlist_places.get({ | |
| plain: true | |
| })) | |
| console.log(created) | |
| }) | |
| .then((index) => { | |
| res.status(200).send({ | |
| index, | |
| }); | |
| }) | |
| .catch((error) => { | |
| res.status(500).send({ | |
| errors: [error], | |
| }); | |
| }); | |
| }; |
In your defaults also add
defaults: {
placeId: placeId,
deletedAt: null
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace with