/api/groups and /api/invites refactored, fixed some inserts/updates in which I didn't include the id

This commit is contained in:
Carlos Mesquita
2024-09-07 17:54:10 +01:00
parent 56f374bbfe
commit 7fa4edf37d
12 changed files with 128 additions and 135 deletions

View File

@@ -108,12 +108,14 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
{ id: codeRef.id },
{
$set: {
id: codeRef.id,
...codeInformation,
email: email.trim().toLowerCase(),
name: name.trim(),
...(passport_id ? { passport_id: passport_id.trim() } : {}),
}
}
},
{ upsert: true }
);
}
@@ -125,7 +127,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
// upsert: true -> if it doesnt exist insert
await db.collection("codes").updateOne(
{ id: code },
{ $set: codeInformation },
{ $set: { id: code, ...codeInformation} },
{ upsert: true }
);
}