Briefle words · Code & architecture
Database transaction
A group of database writes that either all succeed or all fail together.
Say it to an AI
Express 5 + Prisma handler for payment.succeeded webhooks that credits the user's wallet. Delivery is at-least-once, so make it idempotent: use event.id as the idempotency key in a unique-keyed table and insert it plus the balance increment in one database transaction.
How an expert would brief the stronger version of “Wallet top-up webhook”.
See it
Try it as a puzzle →Endpoint in a savings app that tops up a user's wallet when the payment provider reports a successful card payment.
Why: A wraps the event-id insert and the balance update in db.$transaction, so an event can't be marked as seen without the money being added.
Related words
Room 4 · Errors & edge cases
Learn “Database transaction” in a five-minute lesson