Lesson 26← back to roadmap
The transaction is the simplest object in the engine. That is by design.
From docs/internals/transaction-engine.md: the transactional collection holds a non-owning pointer to its parent Transaction. Validation runs at enqueue time. commit() walks the op list under the database write lock and applies via per-collection add() / remove(). The destructor rolls back if neither commit nor rollback was called.
cpp
class Transaction {
public:
TransactionCollection collection(std::string name);
void commit();
void rollback();
~Transaction(); // rollback() if !done_
private:
bool done_{false};
std::vector<Op> ops_;
};