Solved some problems with the excel of master statistical
This commit is contained in:
@@ -6,6 +6,28 @@ import {Module} from "@/interfaces";
|
||||
import {getCorporateUser} from "@/resources/user";
|
||||
import {getUserCorporate} from "./groups.be";
|
||||
import {Db, ObjectId} from "mongodb";
|
||||
import client from "@/lib/mongodb";
|
||||
import {MODULE_ARRAY} from "./moduleUtils";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
|
||||
export async function getSpecificExams(ids: string[]) {
|
||||
if (ids.length === 0) return [];
|
||||
|
||||
const exams: Exam[] = (
|
||||
await Promise.all(
|
||||
MODULE_ARRAY.flatMap(
|
||||
async (module) =>
|
||||
await db
|
||||
.collection(module)
|
||||
.find<Exam>({id: {$in: ids}})
|
||||
.toArray(),
|
||||
),
|
||||
)
|
||||
).flat();
|
||||
|
||||
return exams;
|
||||
}
|
||||
|
||||
export const getExams = async (
|
||||
db: Db,
|
||||
|
||||
Reference in New Issue
Block a user