Reputation: 7
I have a little Problem. I got the following simple SQL request:
async userexists(pUsername) {
await this._sequilze.query("SELECT username, userpw, grade FROM users WHERE username = pUser",
{replacements: {pUser: pUsername}})
.then(result => {
console.log(result)
})
}
But I don't know why I get this Errormessage:
UnhandledPromiseRejectionWarning: SequelizeDatabaseError: SQLITE_ERROR: no such column: pUser
I mean, I replace the pUser with my parameter pUsername. It works when inserted into the database.
A request with hardcoded Data is still working too like WHERE grade = 1
I hope you can help me
Thanks in advance,
JN
Upvotes: 0
Views: 42
Reputation:
According to this reference for Sequelize (which it seems you are using): Sequelize replacements doc
You should use ":key" in your SQL query, in your case replace "pUser" with ":pUser" to have it replaced
async userexists(pUsername) {
await this._sequilze.query("SELECT username, userpw, grade FROM users WHERE username = :pUser",
{replacements: {pUser: pUsername}})
.then(result => {
console.log(result)
})
}
Upvotes: 1