作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 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'))
下面是我的 typeorm 等价物。
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' },
});
但不知何故我得到了错误的输出数量。好像 andWhere 不起作用。提前致谢
最佳答案
let qb = this.repository.createQueryBuilder("department");
qb.where("department.type= :type", {type: "Employee"});
qb.andWhere("((department.from_date BETWEEN '2013-01-03'AND '2013-01-09') OR
(department.to_date BETWEEN '2013-01-03' AND '2013-01-09') OR
(department.from_date <= '2013-01-03' AND department.to_date >= '2013-01-09'))");
关于javascript - Typeor find with and & or where block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62004119/
我正在尝试在 typeorm 中构建以下查询。 SELECT * from Department where type = 'Employee' and ((from_date BETWEEN '20
我是一名优秀的程序员,十分优秀!