Created a new system for the Groups that will persist after having entities
This commit is contained in:
@@ -8,11 +8,14 @@ import client from "@/lib/mongodb";
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
|
||||
export async function getUsers() {
|
||||
return await db.collection("users").find<User>({}, { projection: { _id: 0 } }).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: id}, { projection: { _id: 0 } });
|
||||
const user = await db.collection("users").findOne<User>({id: id}, {projection: {_id: 0}});
|
||||
return !!user ? user : undefined;
|
||||
}
|
||||
|
||||
@@ -21,7 +24,7 @@ export async function getSpecificUsers(ids: string[]) {
|
||||
|
||||
return await db
|
||||
.collection("users")
|
||||
.find<User>({id: {$in: ids}}, { projection: { _id: 0 } })
|
||||
.find<User>({id: {$in: ids}}, {projection: {_id: 0}})
|
||||
.toArray();
|
||||
}
|
||||
|
||||
@@ -46,6 +49,7 @@ export async function getLinkedUsers(
|
||||
.skip(page && size ? page * size : 0)
|
||||
.limit(size || 0)
|
||||
.toArray();
|
||||
|
||||
const total = await db.collection("users").countDocuments(filters);
|
||||
return {users, total};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user