You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.0 KiB
111 lines
4.0 KiB
// Generated by LeStorageGenerator
|
|
// Do not modify this file manually
|
|
|
|
import Foundation
|
|
import LeStorage
|
|
import SwiftUI
|
|
|
|
@Observable
|
|
public class BaseTeamScore: SyncedModelObject, SyncedStorable {
|
|
|
|
public static func resourceName() -> String { return "team-scores" }
|
|
public static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
|
|
public static var copyServerResponse: Bool = false
|
|
public static func storeParent() -> Bool { return false }
|
|
|
|
public var id: String = Store.randomId()
|
|
public var match: String = ""
|
|
public var teamRegistration: String? = nil
|
|
public var score: String? = nil
|
|
public var walkOut: Int? = nil
|
|
public var luckyLoser: Int? = nil
|
|
|
|
public init(
|
|
id: String = Store.randomId(),
|
|
match: String = "",
|
|
teamRegistration: String? = nil,
|
|
score: String? = nil,
|
|
walkOut: Int? = nil,
|
|
luckyLoser: Int? = nil
|
|
) {
|
|
super.init()
|
|
self.id = id
|
|
self.match = match
|
|
self.teamRegistration = teamRegistration
|
|
self.score = score
|
|
self.walkOut = walkOut
|
|
self.luckyLoser = luckyLoser
|
|
}
|
|
required public override init() {
|
|
super.init()
|
|
}
|
|
|
|
public enum CodingKeys: String, CodingKey {
|
|
case _id = "id"
|
|
case _match = "match"
|
|
case _teamRegistration = "teamRegistration"
|
|
case _score = "score"
|
|
case _walkOut = "walkOut"
|
|
case _luckyLoser = "luckyLoser"
|
|
}
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId()
|
|
self.match = try container.decodeIfPresent(String.self, forKey: ._match) ?? ""
|
|
self.teamRegistration = try container.decodeIfPresent(String.self, forKey: ._teamRegistration) ?? nil
|
|
self.score = try container.decodeIfPresent(String.self, forKey: ._score) ?? nil
|
|
self.walkOut = try container.decodeIfPresent(Int.self, forKey: ._walkOut) ?? nil
|
|
self.luckyLoser = try container.decodeIfPresent(Int.self, forKey: ._luckyLoser) ?? nil
|
|
try super.init(from: decoder)
|
|
}
|
|
|
|
public override func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encode(self.id, forKey: ._id)
|
|
try container.encode(self.match, forKey: ._match)
|
|
try container.encode(self.teamRegistration, forKey: ._teamRegistration)
|
|
try container.encode(self.score, forKey: ._score)
|
|
try container.encode(self.walkOut, forKey: ._walkOut)
|
|
try container.encode(self.luckyLoser, forKey: ._luckyLoser)
|
|
try super.encode(to: encoder)
|
|
}
|
|
|
|
func matchValue() -> Match? {
|
|
return self.store?.findById(match)
|
|
}
|
|
|
|
func teamRegistrationValue() -> TeamRegistration? {
|
|
guard let teamRegistration = self.teamRegistration else { return nil }
|
|
return self.store?.findById(teamRegistration)
|
|
}
|
|
|
|
public func copy(from other: any Storable) {
|
|
guard let teamscore = other as? BaseTeamScore else { return }
|
|
self.id = teamscore.id
|
|
self.match = teamscore.match
|
|
self.teamRegistration = teamscore.teamRegistration
|
|
self.score = teamscore.score
|
|
self.walkOut = teamscore.walkOut
|
|
self.luckyLoser = teamscore.luckyLoser
|
|
}
|
|
|
|
public static func parentRelationships() -> [Relationship] {
|
|
return [
|
|
Relationship(type: Match.self, keyPath: \BaseTeamScore.match, storeLookup: .same),
|
|
Relationship(type: TeamRegistration.self, keyPath: \BaseTeamScore.teamRegistration, storeLookup: .same),
|
|
]
|
|
}
|
|
|
|
public static func childrenRelationships() -> [Relationship] {
|
|
return []
|
|
}
|
|
|
|
public static func relationships() -> [Relationship] {
|
|
var relationships: [Relationship] = []
|
|
relationships.append(contentsOf: parentRelationships())
|
|
relationships.append(contentsOf: childrenRelationships())
|
|
return relationships
|
|
}
|
|
|
|
} |