delete /group
Gruppe mit allen Items löschen
This commit is contained in:
parent
84705cd155
commit
ed1e752ace
@ -203,6 +203,21 @@ async function editItem(sl_id, group_id, item_id, name, count) {
|
||||
}
|
||||
}
|
||||
|
||||
//Delete Group
|
||||
|
||||
async function deleteGroup(group_id, sl_id) {
|
||||
try {
|
||||
//Alle Items der Group löschen
|
||||
nonQuery('DELETE FROM "Item" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
|
||||
|
||||
//Leere Gruppe löschen
|
||||
nonQuery('DELETE FROM "Group" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -312,5 +327,5 @@ function generateInviteLink() {
|
||||
|
||||
module.exports = {
|
||||
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem
|
||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup
|
||||
}
|
||||
|
@ -243,6 +243,15 @@ router.put("/item", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/group", async(req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.deleteGroup(req.body.group_id, req.body.sl_id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
|
||||
// Invite System
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user