Refactored discounts and replaced my previous commit id queries to use id not _id
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type {NextApiRequest, NextApiResponse} from "next";
|
||||
import client from "@/lib/mongodb";
|
||||
import { ObjectId } from 'mongodb';
|
||||
import {withIronSessionApiRoute} from "iron-session/next";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import {uuidv4} from "@firebase/util";
|
||||
@@ -130,7 +129,7 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
|
||||
}
|
||||
|
||||
await db.collection("assignments").insertOne({
|
||||
_id: new ObjectId(uuidv4()),
|
||||
id: uuidv4(),
|
||||
assigner: req.session.user?.id,
|
||||
assignees,
|
||||
results: [],
|
||||
@@ -143,7 +142,7 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
for (const assigneeID of assignees) {
|
||||
|
||||
const assignee = await db.collection("users").findOne<User>({ _id: new ObjectId(assigneeID) });
|
||||
const assignee = await db.collection("users").findOne<User>({ id: assigneeID });
|
||||
if (!assignee) continue;
|
||||
|
||||
const name = body.name;
|
||||
|
||||
Reference in New Issue
Block a user