Typeorm 的 Raw() , Between() 在 Find 方法中不起作用
Typeorm's Raw() , Between() not working in Find method
如果我在 Find() 的选项中正常使用 Raw() 函数是有效的,但如果我在另一个函数中编写 Raw() 然后调用 Find() 的选项不起作用
..
import {Raw} from 'typeorm'
-工作状态:
const result = await myEntity.find({
where: {
issueDate:Raw(alias => `${alias} >= :start AND ${alias} < :end`,
{
start: '2021-06-01', end: '2021-06-02'
}
)
});
-不工作的状态:
filter() {
return Raw(alias => `${alias} >= :start AND ${alias} < :end`, {
start: '2021-06-01', end: '2021-06-02' });
}
const result = await myEntity.find({
where: {
issueDate:filter(),
}
});
简单地说,你应该使用where out of find方法
像这样:
const where={ issueDate:filter()}
const result = await myEntity.find({where});
如果我在 Find() 的选项中正常使用 Raw() 函数是有效的,但如果我在另一个函数中编写 Raw() 然后调用 Find() 的选项不起作用
..
import {Raw} from 'typeorm'
-工作状态:
const result = await myEntity.find({
where: {
issueDate:Raw(alias => `${alias} >= :start AND ${alias} < :end`,
{
start: '2021-06-01', end: '2021-06-02'
}
)
});
-不工作的状态:
filter() {
return Raw(alias => `${alias} >= :start AND ${alias} < :end`, {
start: '2021-06-01', end: '2021-06-02' });
}
const result = await myEntity.find({
where: {
issueDate:filter(),
}
});
简单地说,你应该使用where out of find方法 像这样:
const where={ issueDate:filter()}
const result = await myEntity.find({where});