Libraries v5.0.0
    Preparing search index...
    • Execute a captured raw SELECT with an explicit complete output schema. SQL must alias columns to the output property names. Each driver row is parsed exactly once; there is no implicit column mapping or entity decoding. Cast exact numeric values to text in SQL before a driver can lose their precision.

      Type Parameters

      Parameters

      • knex: Knex

        Connection or transaction used for execution.

      • output: S

        Synchronous Framework object schema describing every returned row.

      • queryOrSql: string | QueryBuilder<any, any>

        Trusted SELECT SQL or an independently captured Knex SELECT.

      • bindings: readonly RawBinding[] = []

        Bound values for the trusted SQL string.

      Returns Promise<InferType<S>[]>

      Parsed rows, never attached to an ORM identity map.

      const totals = await rawQuery(knex, object({ total: string() }),
      'select sum(amount)::text as total from invoices where owner_id = ?', [ownerId]);