Added aggregate function querying and deletion querying

This commit is contained in:
John Rommel Estropia
2015-03-05 14:24:26 +08:00
parent 55dee6ec2f
commit 1fae78434f
20 changed files with 730 additions and 84 deletions

View File

@@ -41,8 +41,8 @@ public class AsynchronousDataTransaction: DataTransaction {
*/
public func commit(completion: (result: SaveResult) -> Void) {
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext() == true, "Attempted to commit a \(self.dynamicType) outside a transaction queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a \(self.dynamicType) more than once.")
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to commit a <\(self.dynamicType)> outside a transaction queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a <\(self.dynamicType)> more than once.")
self.isCommitted = true
let semaphore = GCDSemaphore(0)
@@ -62,8 +62,8 @@ public class AsynchronousDataTransaction: DataTransaction {
*/
public func commitAndWait() {
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext() == true, "Attempted to commit a \(self.dynamicType) outside a transaction queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a \(self.dynamicType) more than once.")
HardcoreData.assert(self.transactionQueue.isCurrentExecutionContext(), "Attempted to commit a <\(self.dynamicType)> outside a transaction queue.")
HardcoreData.assert(!self.isCommitted, "Attempted to commit a <\(self.dynamicType)> more than once.")
self.isCommitted = true
self.result = self.context.saveSynchronously()
@@ -100,7 +100,7 @@ public class AsynchronousDataTransaction: DataTransaction {
self.closure(transaction: self)
if !self.isCommitted {
HardcoreData.log(.Warning, message: "The closure for the \(self.dynamicType) completed without being committed. All changes made within the transaction were discarded.")
HardcoreData.log(.Warning, message: "The closure for the <\(self.dynamicType)> completed without being committed. All changes made within the transaction were discarded.")
}
}
}
@@ -112,7 +112,7 @@ public class AsynchronousDataTransaction: DataTransaction {
self.closure(transaction: self)
if !self.isCommitted {
HardcoreData.log(.Warning, message: "The closure for the \(self.dynamicType) completed without being committed. All changes made within the transaction were discarded.")
HardcoreData.log(.Warning, message: "The closure for the <\(self.dynamicType)> completed without being committed. All changes made within the transaction were discarded.")
}
}
return self.result