brianc / node-pg-types

Type parsing for node-postgres
267 stars 54 forks source link

Not able to use with modules #140

Closed Thallius closed 1 year ago

Thallius commented 1 year ago

Hi,

it might be my fault but I am unable to use pg-types with javascript modules.

I tried

import * as pgTypes from 'pg-types'; pgTypes.setTypeParser(1114, function(stringValue) { console.log("Type Parser"); return new Date(stringValue + "+0000"); });

but the function is never called.

Thallius commented 1 year ago

As I said my fault:

The correct way is:

import types from 'pg'; types.types.setTypeParser(1082, function(stringValue) { console.log("Type Parser"); return new Date(stringValue + "+0000"); });