【发布时间】:2021-06-22 17:55:31
【问题描述】:
有一个没有最大项的给定数组,例如:
["DEFAULT", "NEW"], ["REVIEW", "OPEN"], ["DEFAULT", "IN PROGRESS"]
如何使用 typeorm 生成查询,例如
WHERE (tsk.category = DEFAULT AND tsk.status = NEW) OR (tsk.category = REVIEW AND tsk.status = OPEN) OR (tsk.category = DEFAULT and tsk.status = "IN PROGRESS")
以优雅的方式?我可以做类似query.andWhere(query.orWhere())
到目前为止我的代码:
const categories = await categoryService.getAllCategories();
const statusMap = [];
for (const category of categories) {
for (const state of category.states) {
const key = Object.keys(state)[0];
if (state[key].metaState === filter.meta_status) {
statusMap.push([category.name, key]);
}
}
}
【问题讨论】:
标签: sql typescript typeorm node.js-typeorm