interface

SQL.ResultColumn

interface ResultColumn

A column of a PostgreSQL or MySQL result, as the server described it

const result = await sql`SELECT id, data FROM posts`;
console.log(result.columns);
// PostgreSQL:
// [
//   { name: "id", type: 23, table: 16388, number: 1 }, // int4
//   { name: "data", type: 3802, table: 16388, number: 2 }, // jsonb
// ]
  • flags?: number

    MySQL only. The flags of the column, as the server sent them

  • length?: number

    MySQL only. The length of the column, as the server sent it

  • name: string

    The name of the column in the result

  • number?: number

    PostgreSQL only. The number of the column in its table, from 1. 0 for an expression, negative for a system column such as ctid.

  • table: string | number

    The table that the column comes from.

    • PostgreSQL: the OID of the table. 0 for an expression.
    • MySQL: the name of the table, or its alias in the query. "" for an expression.
  • type: number

    The type of the column.

    • PostgreSQL: the OID of the type, such as 23 for int4, 25 for text, 1009 for text[], 3802 for jsonb
    • MySQL: the type code of the protocol, such as 3 for INT, 8 for BIGINT, 253 for VARCHAR, 245 for JSON