Hello everyone!
I do not understand how to put bindings properly in SQL query.
Always I just get 500 error.
I add them as 'PostgresData', then put after query SQL.
It looks like this:
// PostgreSQL
var returnValue: [Song] = []
guard let postgres = req.db as? PostgresDatabase else {
throw Abort(.internalServerError)
}
let id = PostgresData(int32: 289) // add binding
do {
let results = try await postgres.query("SELECT songs FROM bangs WHERE songDuration = $1", [id]).get() // add binding here as an array, '$1' inside the array
for result in results {
returnValue.append(try result.sql().decode(model: Song.self))
}
} catch {
throw Abort(.accepted) // error here!
}
return returnValue
Could you please help me, I am struggling with this for one week looking for any documentation.
Hello everyone! I do not understand how to put bindings properly in SQL query. Always I just get 500 error. I add them as 'PostgresData', then put after query SQL. It looks like this:
Could you please help me, I am struggling with this for one week looking for any documentation.