RecordBox

public final class RecordBox<T: RowConvertible & MutablePersistable>: Record

RecordBox is a subclass of Record that aims at giving any record type the changes tracking provided by the Record class.

// A Regular record struct
struct Player: RowConvertible, MutablePersistable, Codable {
    static let databaseTableName = "players"
    var id: Int64?
    var name: String
    var score: Int
    mutating func didInsert(with rowID: Int64, for column: String?) {
        id = rowID
    }
}

try dbQueue.inDatabase { db in
    // Fetch a player record
    let playerRecord = try RecordBox<Player>.fetchOne(db, key: 1)!

    // Profit from changes tracking
    playerRecord.value.score = 300
    playerRecord.hasPersistentChangedValues         // true
    playerRecord.persistentChangedValues["score"]   // 100 (the old value)
}