use the new _findOrCreate in updated event too

This commit is contained in:
lesion 2022-06-21 22:46:30 +02:00
parent b5b31f0327
commit 660b866f2f
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -534,12 +534,14 @@ const eventController = {
})
await event.setPlace(place)
await event.setTags([])
// create/assign tags
let tags = []
if (body.tags) {
await Tag.bulkCreate(body.tags.map(t => ({ tag: t })), { ignoreDuplicates: true })
const tags = await Tag.findAll({ where: { tag: { [Op.in]: body.tags } } })
await event.addTags(tags)
tags = await tagController._findOrCreate(body.tags)
await event.setTags(tags)
}
const newEvent = await Event.findByPk(event.id, { include: [Tag, Place] })
res.json(newEvent)