Files
cod-backend/Sources/App/Models/Statistics.swift
2021-08-04 16:32:17 -05:00

63 lines
1.2 KiB
Swift

//
// 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
}
}