Skip to content
Latchkey

What Is a Unit of Work?

A unit of work is a pattern that records all the objects loaded or modified within a single operation and writes them out together when the operation completes. It coordinates the changes into one transaction, deciding the order of inserts, updates, and deletes. If anything fails, the whole set can be rolled back as a unit.

Why it matters

Batching related changes into one transaction keeps data consistent and reduces round trips. It gives a clear boundary for committing or discarding an entire operation.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →