T
TanStack13h ago
ambitious-aqua

How to get update server id after onInsert?

In onInsert I'm calling my TRPC endpoint which return the server generate Public ID of the newly inserted item. How can I access that data where I called Collection.insert?
No description
No description
4 Replies
other-emerald
other-emerald12h ago
hmm good question — the transaction itself would be the logical place to put this information as it's what connects the two call sites. But it doesn't have a way to put response data on it atm we should add something for this
ambitious-aqua
ambitious-aquaOP11h ago
Yeah I thought the same thing 😄 Should I file an issue?
other-emerald
other-emerald11h ago
yes please 😄
ambitious-aqua
ambitious-aquaOP11h ago
GitHub
Adding server-generated properties to transaction in Collection.onI...
In my onInsert handler, I call a TRPC endpoint which returns the server-generated publicId of the newly created document: onInsert: async ({ transaction }) => { const newDocument = transaction.m...

Did you find this page helpful?