2

I use SQLite.SWIFT and want to delete rows with specific id from my table.

The documentation here said that I can use:

let delete = delete.update(email <- "alice@me.com")
if let changes = delete.changes where changes > 0 {
    println("deleted alice")
} else if delete.statement.failed {
    println("delete failed: \(delete.statement.reason)")
}

I could not find a global delete function. My table is

let users = db["users"]

How do I perform the delete.update function?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Michael
  • 32,527
  • 49
  • 210
  • 370

1 Answers1

3

That would appear to be a typo in the documentation. You can do something like so:

let alice = users.filter(email == "alice@mac.com")
let delete = alice.delete()
if let changes = delete.changes where changes > 0 {
    println("removed \(changes) record(s) for Alice")
} else if delete.statement.failed {
    println("delete failed: \(delete.statement.reason)")
}
Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • 1
    FYI, I've posted issue [#179](https://github.com/stephencelis/SQLite.swift/issues/179), so we'll see what the author has to say. – Rob Aug 18 '15 at 17:19