我的代码是这样的:
db.run(`begin transaction;
replace into players (user_id, role) values ($id, $role);
update signed_up_users set finalised = 1 where user_id = $id;
commit;`, { $id: id, $role: role}, err=>{
if (err) {throw err;}
});
我收到以下错误:
Error: SQLITE_RANGE: bind or column index out of range
--> in Database#run('begin transaction;\n replace into players (user_id, role) values (?, ?);\n update signed_up_users set finalised = 1 where user_id = ?;\n commit;', [ '123', 'INNOCENT', '123' ], [Function])
at Object.exports.finalise_user (C:\whatever\file.js)
at user.resolve_to_id.then.id (C:\whatever\file.js:52:14)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
如果我正确理解了文档,我的声明中就有适量的参数和占位符。那么我做错了什么?谢谢。