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:
| Category | JS type |
|---|---|
string, uuid, enum | string |
integer | number (or bigint if raw is bigint) |
decimal | string (preserves precision) |
boolean | boolean |
date, timestamp, time | Date |
json | pass-through |
binary | pass-through |
array | pass-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/bigintstrings -> JSbigintjson/jsonbstrings -> parsed objects- Invalid JSON strings kept as-is
MySQL parser
MySQLRecordParser extends the default with:
bigintstrings -> JSbiginttinyint(1)numeric0/1-> JSbooleanjsonstrings -> 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);