diff --git a/sockets/addCommand.js b/sockets/addCommand.js index b9761f7..f258fa8 100644 --- a/sockets/addCommand.js +++ b/sockets/addCommand.js @@ -25,11 +25,11 @@ module.exports = socket => { for (let s of data.sauce) await c.addSauce(await models.Sauce.findByPk(s)); if (data.drink) - await c.addDrink(await models.Drink.findByPk(data.drink)); + await c.setDrink(await models.Drink.findByPk(data.drink)); if (data.dessert) await c.setDessert(await models.Dessert.findByPk(data.dessert)); - let send = utils.commandExport(c); + let send = utils.commandExport(await models.Command.findByPk(c.id, {include: [models.Dish, models.Ingredient, models.Sauce, models.Drink, models.Dessert, "client", "pc", "sandwich"]})); socket.emit("new command", send); socket.broadcast.emit("new command", send); } catch (e) { diff --git a/sockets/utils.js b/sockets/utils.js index 93322f1..138e076 100644 --- a/sockets/utils.js +++ b/sockets/utils.js @@ -1,6 +1,6 @@ const models = require("../models"); -function commandExport (c ) { +function commandExport (c) { return { number: c.number, sandwich: c.sandwich ? c.sandwich.username : null,