It would be nice if I could set the default schema to use for a connection using pg-promise.
What I've tried
I've seen that it was possible in some languages to add ?searchpath=<schema>
to the connection string to set <schema>
as the default schema for subsequent queries, but that does not work in pg-promise.
I've also tried something like this:
const database = pgp(connectionString); // connectionString defined earlier, obviously
database.none('SET search_path TO ${schema}`, { schema: '<schema>' });
...but that, too, seems not to affect following queries.
I also found this related question which doesn't have an accepted answer and in the comments seems to suggest either setting it at the user level, which I don't have the rights to do, or the above, which doesn't seem to work for me.
And I found this question that ended up having a different problem as root cause.
In other words: is there anything else I can try, or should one of the solutions I mentioned above work after all, and if so, how?