Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse array of BigInt #111

Closed
s888 opened this issue Feb 11, 2020 · 3 comments
Closed

Parse array of BigInt #111

s888 opened this issue Feb 11, 2020 · 3 comments

Comments

@s888
Copy link

s888 commented Feb 11, 2020

Hi,
I have a column of type bigint[]
But in response, it is converted to an array of string.

How do I parse it?
This works when the column is of type bigint

import { types } from "pg"
types.setTypeParser(20, BigInt); 

Tried this but it gives an error.

import { Client, types } from "pg"
types.setTypeParser(1016, str => types.arrayParser(str,BigInt));
@bendrucker
Copy link
Collaborator

What error?

@sehrope
Copy link
Contributor

sehrope commented Feb 13, 2020

Must be that arrayParser(...) is no longer re-exported: 09ea625#diff-168726dbe96b3ce427e7fedce31bb0bcL3

Try something like this to use it directly from the postgres-array package:

const { types } = require('pg')
const pgArray = require('postgres-array')
types.setTypeParser(1016, text => pgArray.parse(text, BigInt))

@bendrucker
Copy link
Collaborator

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants