Having CRUD functions and Transaction Support
Hello all,
I'm using Supabase as my DB and SvelteKit both for the frontend and backend.
I decided to create some "CRUD" files, to manage creations and deletions. The purpose would be to set the values of variables such as created_at, created_by (which is a foreign key to user_id), updated_at and updated_by. I was creating my function like this:
However, I now realized that by doing this, I'll not be able to use transactions. Is there any way I can define that 'updatedAt' should be set to the current timestamp and still use transactions?
Thank you!
2 Replies
Ok I think I found a potential solution. Instead of using the drizzle client directly, I added it as an input. This way, I can pass either the drizzle client or the client in the context of the transaction. Rollbacks are working as expected 🙂
Dependency injection baby