sequelize 拿到数据,在服务端直接打印就会出错?
我是使用mysql数据库,使用sequelize 作为代码与数据库的桥接库。 当我直接在server 端打印: console.log(result.total_wx_vote) // undefined ------> 就会出现undefined 但是我若是通过 下面就会出现正确的结果。 console.log(result.dataValues.total_wx_vote)
var result =yield mysqldb.Vote.find({
attributes: [
[Sequelize.fn('SUM', Sequelize.col('wx_vote')), 'total_wx_vote'],
[Sequelize.fn('COUNT', Sequelize.literal('distinct `userid`')), 'total_voted_users']
],
where: {
activity_id: req.query.activity_id
},
});
console.log(result.total_wx_vote) // undefined
console.log(result.dataValues.total_wx_vote)