我们可以在Sequelize v5中将raw:true与findOne方法一起使用吗

时间:2019-10-03 10:03:02

标签: javascript node.js sequelize.js

 User.findOne({ where: { mobile: req.body.mobile }, raw: true })
        .then(userInfo => {
            if (!userInfo) {
                res.json({ status: "failure", data: [], message: "User not Found" })
            } else {
                if (bcrypt.compareSync(req.body.password, userInfo.password)) {

                    var token = jwt.sign({ id: userInfo.id }, process.env.SECRET_KEY, { algorithm: 'HS256' });
                    res.json({ status: "success", token: token, message: "Auth Successful" })
                } else {
                    res.json({ status: "failure", data: [], message: "Auth Failed" })
                }
            }
        }).catch(err => {
            res.json({ status: "failure", data: [], message: "Please provide valid login ID" });
        });

-我正在使用Sequelize V5,节点V8和Mysql DB。 -在文档中,我已经看到raw:true仅适用于findAll()。 -我曾经尝试过findOne()方法,但确实成功了, 但我怀疑这会在将来引起任何问题吗????

0 个答案:

没有答案