From 55f1e7a0d37208ce694cda893b47f913df845e3d Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Wed, 13 Mar 2024 19:04:46 +0100 Subject: [PATCH] create group gateway --- users/userservice/UserController.js | 10 ++++++++-- users/userservice/user-model.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/users/userservice/UserController.js b/users/userservice/UserController.js index 4a6d24f..a3244ee 100644 --- a/users/userservice/UserController.js +++ b/users/userservice/UserController.js @@ -111,11 +111,17 @@ let UserController = { res.json(user); }, addGroupToUser: async (req, res) => { - const { uuid } = req.body; + const { groupUUID } = req.body; const { userUUID } = req.params; const user = await User.findOne({ uuid: userUUID }); - user.groupUUID = uuid; + if (user) { + user.groupId = groupUUID; + await user.save(); + } else { + throw new Error(`User with UUID ${p.uuid} not found`); + } const response = await user.save(); + console.log(response) res.json(response); } diff --git a/users/userservice/user-model.js b/users/userservice/user-model.js index c03c289..195f1c5 100644 --- a/users/userservice/user-model.js +++ b/users/userservice/user-model.js @@ -38,7 +38,7 @@ const userSchema = new mongoose.Schema({ type: Number, required: false, }, - groupUUID:{ + groupId:{ type: String, required: false, }