为什么对象返回而不是NodeJS中的count number sequelize.js

时间:2016-03-14 06:34:35

标签: javascript node.js express sequelize.js

我无法说服为什么对象返回而不是NodeJS中的计数sequelize.js

exports.getApplicationsCountForJobSeekerByUser = function (jobSeekerId, jobId) {
    return sequelize.query('select count(id) from applications where job_seeker_id = :jsId and job_id = :jId',
        { replacements: {jsId: jobSeekerId, jId: jobId}, raw: true, type: sequelize.QueryTypes.SELECT });
};

请告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

退回的对象是承诺。你应该这样做:

getApplicationsCountForJobSeekerByUser.then(function(results){ /* do what you want with query results */}).catch(/* error handling*/)