我在nodejs中使用sequelizejs作为SQLite。我试着得到像这样的SQL:
SELECT
id,
description,
created_at,
postponed,
done_at
FROM tasks
WHERE done_at IS NULL
ORDER by (id+postponed),postponed,id ASC
LIMIT 1
问题是id+postponed
中的OREDR BY
一词
我试过这个:
Task.find({
where: ["done_at is not null"],
order: [["(id+postponed)", "ASC"], ["postponed", "ASC"], ["id", "ASC"]],
limit: 1
}).then(...)
但查询变为:ORDER BY task.(task_id+postponed) ASC, task.postponed ASC, task.task_id ASC
有人知道如何解决这个问题吗?
答案 0 :(得分:0)
我自己找到了解决方案:
Task.find({
where: ["done_at is not null"],
order: '(id+postponed),postponed,id ASC',
limit: 1
}).then(...)
这不完美但对我有用。