Hello, I'm working on my database finding products and I want to filter it by stage, there are 3 stages, DRAFT, PUBLISHED, and ARCHIVED, and e.g. the stage for PUBLISHED product is when new Date() is between published_at and archived_at field, which are timestamp type in TypeORM postgres, but it doesn't work... bots MoreThan/LessThan operators don't find anything. I wrote a function to detect stage and return an object which returns statements to { where } object of find function from repository
export const getStage = (
stage: Stage
): { published_at?: FindOperator<Date> | null; archived_at?: FindOperator<Date> | null } => {
switch (stage) {
case Stage.DRAFT:
return { published_at: LessThan(new Date()) || null, archived_at: LessThan(new Date()) || null }
case Stage.PUBLISHED:
return { published_at: MoreThanOrEqual(new Date()) }
case Stage.ARCHIVED:
return { archived_at: MoreThan(new Date()) }
}
}```
Any advices?