More mongodb migration bugs, remove _id from find, and a stat endpoint firebase leftover bug
This commit is contained in:
@@ -16,5 +16,5 @@ async function GET(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const snapshot = await db.collection("stats").findOne({ id: id as string});
|
const snapshot = await db.collection("stats").findOne({ id: id as string});
|
||||||
if (!snapshot) return res.status(404).json({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});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import client from "@/lib/mongodb";
|
|||||||
const db = client.db(process.env.MONGODB_DB);
|
const db = client.db(process.env.MONGODB_DB);
|
||||||
|
|
||||||
export async function getUsers() {
|
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> {
|
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;
|
return !!user ? user : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export async function getSpecificUsers(ids: string[]) {
|
|||||||
|
|
||||||
return await db
|
return await db
|
||||||
.collection("users")
|
.collection("users")
|
||||||
.find<User>({id: {$in: ids}})
|
.find<User>({id: {$in: ids}}, { projection: { _id: 0 } })
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user