order workflows table in descent startDate

This commit is contained in:
Joao Correia
2025-03-02 00:21:30 +00:00
parent 32cd8495d6
commit 3ef7998193

View File

@@ -19,7 +19,11 @@ export const getApprovalWorkflows = async (collection: string, entityIds?: strin
filters["steps.assignees"] = assignee;
}
return await db.collection<ApprovalWorkflow>(collection).find(filters).toArray();
return await db
.collection<ApprovalWorkflow>(collection)
.find(filters)
.sort({ startDate: -1 })
.toArray();
};
export const getApprovalWorkflow = async (collection: string, id: string) => {
@@ -30,6 +34,7 @@ export const getApprovalWorkflowsByEntities = async (collection: string, ids: st
return await db
.collection<ApprovalWorkflow>(collection)
.find({ entityId: { $in: ids } })
.sort({ startDate: -1 })
.toArray();
};