filter workflows user can see based on entities
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user