I'm using Typeorm as my ORM and I don't know how to express cross join lateral in Typeorm
I have 2 tables: WorkingTime m-1 Worker
WorkingTime entity:
- dayOfWeek: Int
- periods: jsonb
- worker: (Many to one) relationship with Worker table
Below is periods json structure:
[{
start: "10:00:00",
end: "13:00:00
}, {
start: "15:00:00",
end: "21:00:00"
}]
I wanted to get all the Workers whose workingTimes contain periods that have start < 12:00:00
and I used cross join lateral
SELECT DISTINCT "worker".id
FROM "worker" "worker"
LEFT JOIN "working_time" "workingTimes"
ON "workingTimes"."workerId"="worker"."id"
CROSS JOIN LATERAL
jsonb_array_elements("workingTimes"."periods")AS attr
WHERE attr ->> 'start' < '12:00:00'
But I don't know how to express the query using Typeorm (NestJS)