FaasJS
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security

Documents / @faasjs/pg

@faasjs/pg / sql

Variable: sql

const sql: (strings, ...values) => SqlExpression & object

Creates a parameterized SQL expression for QueryBuilder.update.

Use sql.ref for identifiers. All other interpolated values are converted to bound parameters; never concatenate runtime input into the static template text.

Type Declaration

ref

ref: (identifier) => SqlReference

Creates an escaped SQL identifier reference for interpolation into sql.

Parameters

identifier

string

Returns

SqlReference

Example

await client
  .query('jobs')
  .where('id', id)
  .update({
    attempts: sql`${sql.ref('attempts')} + ${1}`,
    updated_at: sql`NOW()`,
  })