Skip to content

Commit

Permalink
create group gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Mar 13, 2024
1 parent cf7899b commit 55f1e7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions users/userservice/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion users/userservice/user-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const userSchema = new mongoose.Schema({
type: Number,
required: false,
},
groupUUID:{
groupId:{
type: String,
required: false,
}
Expand Down

0 comments on commit 55f1e7a

Please sign in to comment.