Refactored discounts and replaced my previous commit id queries to use id not _id
This commit is contained in:
@@ -12,7 +12,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
// verify if it's a logged user that is trying to archive
|
||||
if (req.session.user) {
|
||||
const { id } = req.query as { id: string };
|
||||
const doc = await db.collection("assignments").findOne({ _id: new ObjectId(id) });
|
||||
const doc = await db.collection("assignments").findOne({ id: id });
|
||||
|
||||
if (!doc) {
|
||||
res.status(404).json({ ok: false });
|
||||
@@ -20,10 +20,10 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
}
|
||||
|
||||
await db.collection("assignments").updateOne(
|
||||
{ _id: new ObjectId(id) },
|
||||
{ id: id },
|
||||
{ $set: { released: true } }
|
||||
);
|
||||
|
||||
|
||||
res.status(200).json({ ok: true });
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user