Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Update a sqlite table
//where Medicine is an encodable, decodable struct
fileprivate static let medicineTable = Table("medicine")
fileprivate static let counterTable = Table("counter")
fileprivate static let medicineColumn = Expression<Int>("medicine")
fileprivate static let idColumn = Expression<Int64>("id")
static func update(item: Medicine, onCompletion: (Bool, Error?) -> ()) {
guard let db = SQLiteDataEngine.shared.db else {
onCompletion(false, DataAccessError.Database_Connection_Error)
guard != nil, let itemId = Int64(exactly:!) else {
onCompletion(false, DataAccessError.Nil_In_Data)
do {
let selected = medicineTable.filter(idColumn == itemId)
_ = try
onCompletion(true, nil)
} catch {
onCompletion(false, error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.