From b311735e97bedd764f2e6d43afe8d24bb4fb67a1 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Wed, 1 Aug 2018 23:42:30 +0000 Subject: [groups] add create functionality --- server/api/clients.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server/api/clients.js') diff --git a/server/api/clients.js b/server/api/clients.js index 5bb2a1b..1f28c0b 100644 --- a/server/api/clients.js +++ b/server/api/clients.js @@ -28,7 +28,7 @@ module.exports.get = { // POST Requests module.exports.post = { // create client or update information of a client (returns id) - saveInfo: function (req, res) { + updateOrCreate: function (req, res) { const id = req.body.id > 0 ? req.body.id : null if (id) { db.client.findOne({ where: { id: id } }).then(client => { @@ -38,7 +38,9 @@ module.exports.post = { Promise.all(promises).then(() => { res.send({id}) }) }) } else { - res.end() + db.client.create(req.body.info).then(client => { + if (req.body.groupIds) client.setGroups(req.body.groupIds).then(() => { res.send({ id: client.id }) }) + }) } } } -- cgit v1.2.3-55-g7522