Split Read/Write Traffic #440
-
Hello, How can I split read/write traffic? Ideally, I'd like to be able to pass into the Is this a feature request or does this already exist? I saw the Multi Host Connection Details portion of the docs but it doesn't really answer my question (I think). For context, I'm using Amazon RDS Aurora Cluster with a reader instance and a writer instance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 So basically: const sql = postgres({ ...writableConnectionDetails })
const readOnly = postgres({ ...readOnlyConnectionDetails }) And then use the appropriate one where necessary. |
Beta Was this translation helpful? Give feedback.
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:
And then use the appropriate one where necessary.