// // WinLossRecords.swift // Statistics // // Created by Michael Simard on 8/2/21. // import Fluent import Vapor final class WinLossRecords: Model, Content { // Name of the table or collection. static let schema = "win_loss_records" @ID(key: .id) var id: UUID? @Field(key: "title") var title: String @Field(key: "wins") var wins: Int @Field(key: "losses") var losses: Int @Field(key: "cod_tracker_id") var codTrackerId: String // Creates a new, empty . init() { } // Creates a new with all properties set. init(id: UUID? = nil, title: String, wins: Int, losses: Int, codTrackerId:String) { self.id = id self.title = title self.wins = wins self.losses = losses self.codTrackerId = codTrackerId } func update( statistics:WinLossRecords) { print ("saving: \(statistics.codTrackerId)") guard let _ = statistics.id else { return } print ("saving: \(statistics)") self.id = statistics.id self.title = statistics.title self.wins = statistics.wins self.losses = statistics.losses self.codTrackerId = statistics.codTrackerId } }