method
TransactionSQL.unsafe
Executes any query string as-is. This can lead to SQL injection if the string contains untrusted input.
sql.unsafe can be nested inside a safe sql expression, for example when only part of the query is unsafe.
With the SQLite adapter, values may also be an object of named parameters (:name, $name, or @name placeholders). Object keys keep the prefix unless the connection sets strict: true.
const result = await sql.unsafe(`select ${danger} from users where id = ${dragons}`)
const row = await sql.unsafe("select * from users where id = :id", { ":id": 1 })Referenced types
interface Query<T>
A pending SQL query. Extends Promise, so it can be awaited, and adds methods to control how it runs.
- onrejected?: null | (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
Attaches a callback for only the rejection of the Promise.
@param onrejectedThe callback to execute when the Promise is rejected.
@returnsA Promise for the completion of the callback.
- onfinally?: null | () => void): Promise<T>;
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
@param onfinallyThe callback to execute when the Promise is settled (fulfilled or rejected).
@returnsA Promise for the completion of the callback.
- onfulfilled?: null | (value: T) => TResult1 | PromiseLike<TResult1>,onrejected?: null | (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
Attaches callbacks for the resolution and/or rejection of the Promise.
@param onfulfilledThe callback to execute when the Promise is resolved.
@param onrejectedThe callback to execute when the Promise is rejected.
@returnsA Promise for the completion of which ever callback is executed.