我有这样的查询:
SELECT merchant_id as name,count(id) as y FROM table_name WHERE DATE(created_at) = current_date() GROUP BY merchant_id
我将在Squijize中以hapijs运行此查询。
我尝试这样,但是不起作用,返回空数组
return new Promise(async function (resolve, reject) {
return await sequelize.query(query, { type: sequelize.QueryTypes.SELECT})
.then(users => {
resolve(users)
})
.catch(error => {
reject(error)
})
});
答案 0 :(得分:0)
该怎么办?
return new Promise(async (resolve, reject) => {
try {
const users = await sequelize.query(query, { type: sequelize.QueryTypes.SELECT})
resolve(users)
} catch (error) {
reject(error)
}
});