Skip to main content

Record parsing

After a query executes, the RecordParser coerces raw driver output into typed JavaScript values using the field metadata from the DataModel.

Default parser

DefaultRecordParser handles all categories:

CategoryJS type
string, uuid, enumstring
integernumber (or bigint if raw is bigint)
decimalstring (preserves precision)
booleanboolean
date, timestamp, timeDate
jsonpass-through
binarypass-through
arraypass-through if array, else []

Null and undefined values become null. Fields absent from the row are omitted from the result (partial projection support).

Postgres parser

PostgresRecordParser extends the default with:

  • int8 / bigint strings -> JS bigint
  • json / jsonb strings -> parsed objects
  • Invalid JSON strings kept as-is

MySQL parser

MySQLRecordParser extends the default with:

  • bigint strings -> JS bigint
  • tinyint(1) numeric 0/1 -> JS boolean
  • json strings -> parsed objects
  • Invalid JSON strings kept as-is

Output formatters

The SDK includes formatters for serializing parsed records:

import { JsonFormatter, CsvFormatter, RawFormatter } from '@biref/scanner';

// JSON (pretty-printed)
const json = new JsonFormatter({ pretty: true }).serialize(rows);

// CSV with header row
const csv = new CsvFormatter({ includeHeader: true }).serialize(rows);

// Raw (util.inspect)
const raw = new RawFormatter().serialize(rows);