use the new _findOrCreate in updated event too
This commit is contained in:
@@ -534,12 +534,14 @@ const eventController = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await event.setPlace(place)
|
await event.setPlace(place)
|
||||||
await event.setTags([])
|
|
||||||
|
// create/assign tags
|
||||||
|
let tags = []
|
||||||
if (body.tags) {
|
if (body.tags) {
|
||||||
await Tag.bulkCreate(body.tags.map(t => ({ tag: t })), { ignoreDuplicates: true })
|
tags = await tagController._findOrCreate(body.tags)
|
||||||
const tags = await Tag.findAll({ where: { tag: { [Op.in]: body.tags } } })
|
await event.setTags(tags)
|
||||||
await event.addTags(tags)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newEvent = await Event.findByPk(event.id, { include: [Tag, Place] })
|
const newEvent = await Event.findByPk(event.id, { include: [Tag, Place] })
|
||||||
res.json(newEvent)
|
res.json(newEvent)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user