Skip to content

Instantly share code, notes, and snippets.

@basekays
Created May 31, 2018 22:16
Show Gist options
  • Select an option

  • Save basekays/5d8234e62cfaca948c41969016f48acd to your computer and use it in GitHub Desktop.

Select an option

Save basekays/5d8234e62cfaca948c41969016f48acd to your computer and use it in GitHub Desktop.
handler.js
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],
});
});
};
@salbito

salbito commented May 31, 2018

Copy link
Copy Markdown

Replace with

.spread((wishlistPlaces, created) => {
  return wishlistPlaces[0];
})

@salbito

salbito commented May 31, 2018

Copy link
Copy Markdown

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