Database.setRollbackHook

Registers a delegate as the database's commit or rollback hook. Any previously set hook is released.

struct Database
void
setRollbackHook
(
void delegate
()
hook
)

Parameters

hook void delegate
()

For the commit hook, a delegate that should return 0 if the operation must be aborted or another value if it can continue.

Examples

int i;
auto db = Database(":memory:");
db.setCommitHook({ i = 42; return SQLITE_OK; });
db.setRollbackHook({ i = 666; });
db.begin();
db.execute("CREATE TABLE test (val INTEGER)");
db.rollback();
assert(i == 666);
db.begin();
db.execute("CREATE TABLE test (val INTEGER)");
db.commit();
assert(i == 42);

See Also

Meta