Merged develop into addedAccess-bugfixes

This commit is contained in:
Francisco Lima
2025-02-09 04:32:42 +00:00
6 changed files with 99 additions and 32 deletions

View File

@@ -4,11 +4,18 @@ import { ObjectId } from "mongodb";
const db = client.db(process.env.MONGODB_DB);
export const getApprovalWorkflows = async (collection: string, ids?: string[]) => {
return await db
.collection<ApprovalWorkflow>(collection)
.find(ids ? { _id: { $in: ids.map((id) => new ObjectId(id)) } } : {})
.toArray();
export const getApprovalWorkflows = async (collection: string, entityIds?: string[], ids?: string[]) => {
const filters: any = {};
if (ids && ids.length > 0) {
filters.id = { $in: ids };
}
if (entityIds && entityIds.length > 0) {
filters.entityId = { $in: entityIds };
}
return await db.collection<ApprovalWorkflow>(collection).find(filters).toArray();
};
export const getApprovalWorkflow = async (collection: string, id: string) => {
@@ -37,9 +44,9 @@ export const getApprovalWorkflowByFormIntaker = async (entityId: string, formInt
export const getApprovalWorkflowsByExamId = async (examId: string) => {
return await db
.collection<ApprovalWorkflow>("active-workflows")
.find({
examId,
status: { $in: ["pending"] }
.find({
examId,
status: { $in: ["pending"] },
})
.toArray();
};