Function to release context post-batching?
In our application every customer has their own schema, therefore we need a db client per request which I was hoping to leverage with TRPC context.
Ideally, we'd be able to:
- Connect to the database in context
- Set the
- Run our procedures using that database connection from context
- Release the database connection after all batching is finished
Is this not currently possible with TRPC? Right now I think I can only connect to the database using a per procedure middleware.
This works, but it requires establishing a connection/search_path for every procedure in a batch, instead of just once in context and releasing after the batch. Is there a way to accomplish this?
Ideally, we'd be able to:
- Connect to the database in context
- Set the
search_path to match the client's JWT in context - Run our procedures using that database connection from context
- Release the database connection after all batching is finished
Is this not currently possible with TRPC? Right now I think I can only connect to the database using a per procedure middleware.
This works, but it requires establishing a connection/search_path for every procedure in a batch, instead of just once in context and releasing after the batch. Is there a way to accomplish this?