datascript

seepel 2024-06-19T02:55:26.826669Z

I’m not quite sure how to ask this question, but does anyone have advice on using :db.fn/call inside a transaction vs passing a conn around?

Sam Ferrell 2024-06-19T03:02:35.946589Z

What kind of advice? My app used to pass conns around but I switched it to using transaction functions via db.fn/call

seepel 2024-06-19T03:10:10.419549Z

Thanks so much for responding. First question on my mind is Do you like it better? I switched my most gnarly “transaction” from passing conns to using :db.fn/call and appreciated some of the ergonomics. But in the middle of the flow I have an async process where I do indeed need to start a new transaction when the async process finishes. So I ended up passing a conn through a callback, but it’s kinda getting in the way.

seepel 2024-06-19T03:10:49.118599Z

Sometimes the async process finishes before the original transaction also… 😅 Which is why I switched to using :`db.fn/call` I wanted to get it as close to the end of the transaction as possible.

Sam Ferrell 2024-06-19T03:33:42.380249Z

Yeah I prefer the built-in fn/call op over passing the atom around generally, I haven't had any issues with running them in async flows since they're sync themselves

Sam Ferrell 2024-06-19T03:34:21.318749Z

Example of a transaction function in my app

seepel 2024-06-19T03:37:25.112279Z

Great, I think I was trying to test if this is an edge case for me or common, and to hear a first hand report. Thank you 🙏