For the commit hook, a delegate that should return 0 if the operation must be aborted or another value if it can continue.
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);
Registers a delegate as the database's commit or rollback hook. Any previously set hook is released.