Skip to content

Commit

Permalink
docs: add bigint type override example
Browse files Browse the repository at this point in the history
  • Loading branch information
adelsz committed Feb 9, 2023
1 parent eae091b commit a223dad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs-new/docs/typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { types } from 'pg'
// DATE are now returned as string instead of Date objects
types.setTypeParser(types.builtins.DATE, (val: string) => val);

// INT8 (bigint) are now returned as BigInt instead of string
types.setTypeParser(types.builtins.INT8, (val: string) => BigInt(val));

// DECIMAL and other precision types are now returned as number instead of string
types.setTypeParser(types.builtins.NUMERIC, (val: string) => Number(val));
```
Expand All @@ -30,6 +33,7 @@ In the config file you can override the default type mapping:
{
"typesOverrides": {
"date": "string",
"int8": "BigInt",
"numeric": "number"
}
}
Expand Down Expand Up @@ -147,4 +151,4 @@ type DefaultMapping = {
// Bytes
'bytea': Buffer,
}
```
```

0 comments on commit a223dad

Please sign in to comment.