Skip to content

Column(s)

Christoph Herrmann edited this page Nov 21, 2019 · 3 revisions
const columns = ['id', 'email']

const result = await sql.query(sql`
  SELECT ${sql.columns(columns)} FROM "users"
`)

// text: SELECT "id", "email" FROM "users"
// values: []

If the parameter is an object (e.g. a user) the keys of the object will be used:

const user = { id: 'id', email: 'email' }

const result = await sql.query(sql`
  SELECT ${sql.columns(user)} FROM users
`)

// text: SELECT "id", "email" FROM "users"
// values: []

A column can also be a Tag Helper, which is used to support JSON Columns.

Clone this wiki locally