InsertionSuccess
The result of a successful record insertion.
InsertionSuccess
gives the auto-incremented id after a successful
record insertion:
struct Player: Encodable, MutablePersistableRecord {
var id: Int64?
var name: String
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
try dbQueue.write { db in
var player = Player(id: nil, name: "Alice")
try player.insert(db)
print(player.id) // The inserted id
}
-
The rowid of the inserted record.
For example:
struct Player: Encodable, MutablePersistableRecord { var id: Int64? var name: String mutating func didInsert(_ inserted: InsertionSuccess) { id = inserted.rowID } }
To learn about rowids, see https://www.sqlite.org/lang_createtable.html#rowids_and_the_integer_primary_key.
-
The name of the eventual INTEGER PRIMARY KEY column.
-
The persistence container that was inserted.
If the database table has a rowid column, the persistence container contains the rowid of the inserted record.