参数化查询"/>
无法在 Nodejs 中使用参数化查询
我正在使用 Nodejs/expressjs,现在我很想执行参数化查询,但是我在 console.log 中收到以下错误,我该如何解决这个问题?
SyntaxError: Missing initializer in destructuring declaration
这是我的代码
[![static async addServiceDetail(shopId,serviceId,genderTypeId,price,serviceName)
{
const sql = `SELECT id from hc_servicesdetail WHERE shopId='${shopId}' AND serviceId='${serviceId}' AND genderTypeId='genderTypeId'`;
const \[rows, fields\] = await pool.execute(sql);
if(rows<1)
{
const sql2 = `INSERT INTO servicesdetail (userId, serviceId, genderTypeId,price,serviceName) VALUES (?, ?, ?, ?, ?)`,\[userId, serviceId, genderTypeId, price, serviceName\]`;
console.log('query is '+ sql);
const \[datass, _\] = await pool.execute(sql2);
console.log('last inserted id is ' +datass.insertId);
}
else
{
console.log('already exist');
}
}
}][1]][1]
回答如下:
更多推荐
无法在 Nodejs 中使用参数化查询
发布评论