var cn = {
host: 'localhost',
port: 5432,
database: 'MyDB',
user: 'user1',
password: '123',
currentSchema:'C0001'
};
PostgreSQL supports many connection parameters, of which the underlying driver node-postgres supports only a sub-set, and as of today the default schema is not supported (not sure if even PostgreSQL supports it).
Other than that, it is a matter for node-postgres, not this library, which only uses it.
The best support for a flexible schema support is available through Query Files. See also pg-promise-demo as an example.
@vitaly-t Query Files. can't meet our needs.
thank you!
See the following discussion: https://github.com/vitaly-t/pg-promise/issues/154
The same approach can solve the issue of setting the schema automatically, on every fresh connection.
var options = {
promiseLib: promise,
connect: function(client){
client.query('SET search_path = cust');
}
};
can be used.
thanks very much!
Almost... as per the discussion that I gave a link previously...
var options = {
promiseLib: promise,
connect: function (client, dc, isFresh) {
if (isFresh) {
client.query('SET search_path = cust');
}
}
};
otherwise you will end up executing it non-stop for each connection request from the pool.
Version 8.3.0 simplifies this, with automatic support for option schema.
Version 8.4.0 affects the functionality described here.
The easiest is to avoid use of event connect for this, and just use option schema instead.
Most helpful comment
Almost... as per the discussion that I gave a link previously...
otherwise you will end up executing it non-stop for each connection request from the pool.