我有一个模型设置,并且正在执行带有一些分组和不同计数的SQL查询。然而,sequelize将这些计数作为字符串返回。如何将其作为数字返回,或者我将不得不手动转换结果集?
report_table.findAll({
attributes: [
[report_table.sequelize.fn("concat", report_table.sequelize.col("application"), report_table.sequelize.col("document_title")), "_id"],
"application", "document_title", [report_table.sequelize.fn('count', report_table.sequelize.col('view_id')), "view count"],
[report_table.sequelize.fn('count', report_table.sequelize.fn('DISTINCT', report_table.sequelize.col('client_id'))), "user count"],
[report_table.sequelize.fn('max', report_table.sequelize.col('date')), "last view"]
],
where: {
tag_type: "event",
application: {
$in: applications
}
},
group: ["application", "document_title"],
order: [
[report_table.sequelize.fn('count', report_table.sequelize.col('view_id')), "DESC"]
]
}).then(callback);