1

I'm moving an application from RoR to Express.js. ActiveRecord postgres adapter has the search_path configuration option.

Is it possible to set the search_path for the Client ?

3 Answers3

2

My preference would be to chance this on the database or user if possible.

ALTER [DATABASE or USER] [name] set search_path='[searchpath]'

If that fails you can always make sure your search path is set by building into your connection logic:

SET search_path='[searchpath]'

That will set it on the connection.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
1

Yes sure you can automaticaly triger SET command "on" connection event

pool.on('connect', (client) => {
  client.query('SET search_path TO schema,public');
});
Tim Kozak
  • 4,026
  • 39
  • 44
0
process.env.PGOPTIONS="-c search_path=some_schema"
  • 3
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Oct 11 '22 at 17:12