How to configure types only for a particular instance of node-postgres?
See original GitHub issueIt appears that the only way to configure type parser is by doing so globally, i.e.
var types = require('pg').types
types.setTypeParser(20, function(val) {
return parseInt(val)
});
– https://github.com/brianc/node-pg-types
I would like to restrict type parsing to a particular connection.
Is there an API at the moment to do so?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Queries – node-postgres
The api for executing queries supports both callbacks and promises. I'll provide an example for both styles here. For the sake of brevity...
Read more >Documentation: 15: CREATE TYPE - PostgreSQL
Composite Types. The first form of CREATE TYPE creates a composite type. The composite type is specified by a list of attribute names...
Read more >node-postgres: how to execute "WHERE col IN (<dynamic ...
node -postgres appears to work exclusively with bound parameters: client.query('SELECT * FROM table WHERE id = $1', [ id ]) ; this will...
Read more >Building and running a Node.JS, TypeScript, PostgreSQL app ...
JS enhanced with TypeScript, PostgreSQL as our database, and how to ... For example, after you install the types package, you'll be able...
Read more >CRUD REST API with Node.js, Express, and PostgreSQL
api=> CREATE TABLE users ( ID SERIAL PRIMARY KEY, name VARCHAR(30), email VARCHAR(30) );. Make sure not to use the backtick ` character...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
pg.types
is a convenience reexport; pg itself doesn’t use that property. You can override type parsing by configuration (i.e. per client or pool) by passing something that satisfies the necessary interface in thetypes
property, the most convenient something I’m aware of being aTypeOverrides
from pg/lib/type-overrides.js:Just in case anyone comes across this, if you are using
pg-native
, you also need to overrideclient.native._types
. See https://github.com/gajus/slonik/commit/009a2124264d267681ed9a680db10d94e3990dae.