NodeJS 运算符不存在:text =带有节点js和Postgresql的bigint

vaqhlq81  于 2022-12-12  发布在  Node.js
关注(0)|答案(1)|浏览(124)

我一直收到错误消息“error:运算符不存在:text = bigint”。任何建议都会有帮助!谢谢。如果你知道如何检查令牌是否存在,那也会很有帮助,因为我正在传递它。下面是我的代码:

const  bcrypt  =  require("bcrypt");

const  client  =  require("../configs/database");

const  jwt  =  require("jsonwebtoken");

exports.updateemail  =  async (req, res) => {
    const { 
        id,
        newemail,
        cid
    } =  req.body;

    const query = "UPDATE users SET (email) = ("+newemail+") WHERE id = "+id+" AND cid = "+cid+"";

    try {
        const res = await client.query(query)
        res.status(200).send({ message: 'Success' });
    } catch (err) {
        console.log(err.stack)
        return false;
    }
}
brgchamk

brgchamk1#

我想出了这个解决方案,它的工作。

client.query(
            'UPDATE users SET email = $1 WHERE id = $2 AND cid = $3',
            [newemail, id, cid],
            (error, results) => {
            if (error) {
                throw error
            }
                res.status(200).send(`User modified with ID: ${id}`)
            }
    )

相关问题