update sequelize .spread usage
This commit is contained in:
@@ -275,12 +275,10 @@ const eventController = {
|
||||
|
||||
const event = await Event.create(eventDetails)
|
||||
|
||||
// TOFIX: check if place is specified
|
||||
// create place if needed
|
||||
const place = await Place.findOrCreate({
|
||||
const [place] = await Place.findOrCreate({
|
||||
where: { name: body.place_name },
|
||||
defaults: { address: body.place_address }
|
||||
}).spread((place, created) => place)
|
||||
})
|
||||
|
||||
await event.setPlace(place)
|
||||
event.place = place
|
||||
@@ -356,15 +354,11 @@ const eventController = {
|
||||
}
|
||||
|
||||
await event.update(eventDetails)
|
||||
let place
|
||||
try {
|
||||
place = await Place.findOrCreate({
|
||||
where: { name: body.place_name },
|
||||
defaults: { address: body.place_address }
|
||||
}).spread((place, created) => place)
|
||||
} catch (e) {
|
||||
debug(e)
|
||||
}
|
||||
const [place] = await Place.findOrCreate({
|
||||
where: { name: body.place_name },
|
||||
defaults: { address: body.place_address }
|
||||
})
|
||||
|
||||
await event.setPlace(place)
|
||||
await event.setTags([])
|
||||
if (body.tags) {
|
||||
|
||||
Reference in New Issue
Block a user