Effect CommunityEC
Effect Community8mo ago
2 replies
Near

How to Trigger a Manual Rollback in SQL Transactions Using Effect Typescript

I just started exploring the SQL integration and sadly there is no public documentation yet. Curious about transactions which were mentioned in a previous thread to be written this way:
const sql = yield* SqlClient
const db = yield* Drizzle

yield* sql.withTransaction(
    $(function* () {
        yield* db.delete(players)
        yield* db.insert(players).values({ id: 1, name: 'Alice' })
    }),
)

What is the recommended way to trigger a manual rollback if I happen to run into a situation like that? Judging by the syntax my gut feeling is that yielding an Effect.fail would do the trick, or am I mistaken?
Was this page helpful?