I'm using Stephen Celis iOS lib for handling SQLite3 databases, here is the github link.
Taking the example on the git :
try db.transaction {
let rowid = try db.run(users.insert(email <- "betty@icloud.com"))
try db.run(users.insert(email <- "cathy@icloud.com", managerId <- rowid))
}
// BEGIN DEFERRED TRANSACTION
// INSERT INTO "users" ("email") VALUES ('betty@icloud.com')
// INSERT INTO "users" ("email", "manager_id") VALUES ('cathy@icloud.com', 2)
// COMMIT TRANSACTION
I tried to implement the commitHook block but it is fired for each insert. I'd like to fire an action only when all the requests are sent :-D
What should I do ?
Cheers
Edit : Here is how I implemented the commit hook.
for bay in list{
try! self.themanager.db.transaction {
try! self.themanager.db.run(self.themanager.bays.insert(
//insert values
))
self.themanager.db.commitHook({
print("end commit hook")
})
}
}
Maybe it's related to my main loop :/