MiNiMAL
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
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?13 replies
Dynamic input not leading to changes on the front end
I'm building a dynamic procedure to access my database via Drizzle ORM.
Ideally a developer would be able to send input parameters to the procedure and have it's output adjusted by that input.
For example, in the below, I have a table called
demotable
which has an updatedAt
column. If a developer passes in columns: { updatedAt: false }
to the procedure, then ideally the column would not get included in the result.
If I hard code the columns
parameter in the backend itself, then it works great. Is there a way to accomplish this for the full round trip?
4 replies
Best practices for implementing an offline application
Hey there! I'm building a full stack react-native app with Expo and a tRPC backend. I'd like for this app to be functional offline. Currently I'm accomplishing this via a simple optimistic update like:
This is working pretty well (it's late and I plan on extensively testing this tomorrow). I'd like to confirm what best practices, if any, have been established by the community before continuing.
2 replies