I am trying to build below query in typeorm.
SELECT * from Department where
type = 'Employee' and
((from_date BETWEEN '2013-01-03'AND '2013-01-09') OR
(to_date BETWEEN '2013-01-03' AND '2013-01-09') OR
(from_date <= '2013-01-03' AND to_date >= '2013-01-09'))
Below is my typeorm equivalent.
connection.find(Department, {
where: [
{ fromDate: Between(filter.fromDate, filter.toDate) },
{ toDate: Between(filter.fromDate, filter.toDate) },
{
fromDate: LessThanOrEqual(filter.fromDate),
toDate: MoreThanOrEqual(filter.toDate),
},
],
andWhere: { type: 'Employee' },
});
But somehow I am getting wrong number of output. It is as if andWhere is not working. Thanks in advance