Skip to content

Split Read/Write Traffic #440

Answered by porsager
bestickley asked this question in Q&A
Jul 27, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I think you should create separate instances for that then. You can't decide from the operation alone if you're reading or writing, as you could easily have a mutating function like select some_function_that_writes() etc.

So basically:

const sql = postgres({ ...writableConnectionDetails })

const readOnly = postgres({ ...readOnlyConnectionDetails })

And then use the appropriate one where necessary.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bestickley
Comment options

Answer selected by bestickley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants