More mongodb migration bugs, remove _id from find, and a stat endpoint firebase leftover bug

This commit is contained in:
Carlos Mesquita
2024-09-23 00:04:06 +01:00
parent fb293dc98c
commit 71bac76c3a
2 changed files with 4 additions and 4 deletions

View File

@@ -16,5 +16,5 @@ async function GET(req: NextApiRequest, res: NextApiResponse) {
const snapshot = await db.collection("stats").findOne({ id: id as string});
if (!snapshot) return res.status(404).json({id: id as string});
res.status(200).json({...snapshot.data(), id: snapshot.id});
res.status(200).json({...snapshot, id: snapshot.id});
}

View File

@@ -8,11 +8,11 @@ import client from "@/lib/mongodb";
const db = client.db(process.env.MONGODB_DB);
export async function getUsers() {
return await db.collection("users").find<User>({}).toArray();
return await db.collection("users").find<User>({}, { projection: { _id: 0 } }).toArray();
}
export async function getUser(id: string): Promise<User | undefined> {
const user = await db.collection("users").findOne<User>({id});
const user = await db.collection("users").findOne<User>({id: id}, { projection: { _id: 0 } });
return !!user ? user : undefined;
}
@@ -21,7 +21,7 @@ export async function getSpecificUsers(ids: string[]) {
return await db
.collection("users")
.find<User>({id: {$in: ids}})
.find<User>({id: {$in: ids}}, { projection: { _id: 0 } })
.toArray();
}