2020-05-08 17:49:14 +10:00
|
|
|
//
|
|
|
|
// Encounter+Util.swift
|
|
|
|
// CovidSafe
|
|
|
|
//
|
|
|
|
// Copyright © 2020 Australian Government. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
extension Encounter {
|
|
|
|
@nonobjc public class func deleteAll() {
|
2020-05-26 17:10:41 +10:00
|
|
|
EncounterDB.shared.persistentContainer?.performBackgroundTask { (backgroundContext) in
|
2020-05-08 17:49:14 +10:00
|
|
|
let oldFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Encounter")
|
|
|
|
let batchDeleteRequest = NSBatchDeleteRequest(fetchRequest: oldFetchRequest)
|
|
|
|
do {
|
|
|
|
try backgroundContext.execute(batchDeleteRequest)
|
|
|
|
} catch {
|
|
|
|
DLog("Error deleting old data \(error)")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|