Open kyscott18 opened 2 months ago
It would be great to be able to set a custom type parser for postgres data types at an instance level in addition to the query level. I'd be happy to work on this pr, but wanted to get some input on how it should look first.
import { PGlite, types } from '@electric-sql/pglite'; const pg = await PGlite.create({ parsers: { [types.TEXT]: (value) => value.toUpperCase(), }, }); // or const pg = await PGlite.create(); pg.setParser(types.TEXT, (value) => value.toUpperCase());
It should probably be one or the other, which one do you think fits in best?
node-postgres
var types = require('pg').types; types.setTypeParser(20, function(val) { return parseInt(val, 10) });
drizzle-orm
const users = pgTable('users', { // set custom column type with ".$type" id: serial('id').$type<UserId>().primaryKey(), });
It would be great to be able to set a custom type parser for postgres data types at an instance level in addition to the query level. I'd be happy to work on this pr, but wanted to get some input on how it should look first.
API
It should probably be one or the other, which one do you think fits in best?
Relevant examples
node-postgres
drizzle-orm