diff --git a/PadelClub/Data/Club.swift b/PadelClub/Data/Club.swift index 44b2eaf..fd52b4c 100644 --- a/PadelClub/Data/Club.swift +++ b/PadelClub/Data/Club.swift @@ -15,6 +15,7 @@ class Club : ModelObject, Storable, Hashable { static func resourceName() -> String { return "clubs" } static func tokenExemptedMethods() -> [HTTPMethod] { return [.get] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] static func == (lhs: Club, rhs: Club) -> Bool { lhs.id == rhs.id diff --git a/PadelClub/Data/Court.swift b/PadelClub/Data/Court.swift index 4c54a06..c786f38 100644 --- a/PadelClub/Data/Court.swift +++ b/PadelClub/Data/Court.swift @@ -14,6 +14,7 @@ class Court : ModelObject, Storable, Hashable { static func resourceName() -> String { return "courts" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] static func == (lhs: Court, rhs: Court) -> Bool { lhs.id == rhs.id diff --git a/PadelClub/Data/DateInterval.swift b/PadelClub/Data/DateInterval.swift index 64d79d6..69978f2 100644 --- a/PadelClub/Data/DateInterval.swift +++ b/PadelClub/Data/DateInterval.swift @@ -14,6 +14,7 @@ class DateInterval: ModelObject, Storable { static func resourceName() -> String { return "date-intervals" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var event: String diff --git a/PadelClub/Data/Event.swift b/PadelClub/Data/Event.swift index 7178937..0c60f8b 100644 --- a/PadelClub/Data/Event.swift +++ b/PadelClub/Data/Event.swift @@ -15,6 +15,7 @@ class Event: ModelObject, Storable { static func resourceName() -> String { return "events" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var creator: String? diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index 10d2ec5..5594cfb 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -15,6 +15,7 @@ class GroupStage: ModelObject, Storable { static func resourceName() -> String { "group-stages" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var tournament: String diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index e463920..a8af519 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -13,6 +13,7 @@ class Match: ModelObject, Storable { static func resourceName() -> String { "matches" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = ["round", "groupStage"] static func setServerTitle(upperRound: Round, matchIndex: Int) -> String { if upperRound.index == 0 { return upperRound.roundTitle() } diff --git a/PadelClub/Data/MatchScheduler.swift b/PadelClub/Data/MatchScheduler.swift index d09f9d7..02ab172 100644 --- a/PadelClub/Data/MatchScheduler.swift +++ b/PadelClub/Data/MatchScheduler.swift @@ -15,6 +15,7 @@ class MatchScheduler : ModelObject, Storable { static func resourceName() -> String { return "match-scheduler" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] private(set) var id: String = Store.randomId() var tournament: String diff --git a/PadelClub/Data/MonthData.swift b/PadelClub/Data/MonthData.swift index 94529a7..9db06f5 100644 --- a/PadelClub/Data/MonthData.swift +++ b/PadelClub/Data/MonthData.swift @@ -15,6 +15,7 @@ class MonthData : ModelObject, Storable { static func resourceName() -> String { return "month-data" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] private(set) var id: String = Store.randomId() private(set) var monthKey: String diff --git a/PadelClub/Data/PlayerRegistration.swift b/PadelClub/Data/PlayerRegistration.swift index 09152db..4c6d28c 100644 --- a/PadelClub/Data/PlayerRegistration.swift +++ b/PadelClub/Data/PlayerRegistration.swift @@ -13,6 +13,7 @@ class PlayerRegistration: ModelObject, Storable { static func resourceName() -> String { "player-registrations" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = ["teamRegistration"] var id: String = Store.randomId() var teamRegistration: String? diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 0ece396..58eb8f1 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -14,6 +14,7 @@ class Round: ModelObject, Storable { static func resourceName() -> String { "rounds" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var tournament: String diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index e20446e..84fbde1 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -13,6 +13,7 @@ class TeamRegistration: ModelObject, Storable { static func resourceName() -> String { "team-registrations" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var tournament: String diff --git a/PadelClub/Data/TeamScore.swift b/PadelClub/Data/TeamScore.swift index 1be1738..09caa48 100644 --- a/PadelClub/Data/TeamScore.swift +++ b/PadelClub/Data/TeamScore.swift @@ -14,6 +14,7 @@ class TeamScore: ModelObject, Storable { static func resourceName() -> String { "team-scores" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return true } + static var relationshipNames: [String] = ["match"] var id: String = Store.randomId() var match: String diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 40ddee2..20b1825 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -13,6 +13,7 @@ class Tournament : ModelObject, Storable { static func resourceName() -> String { "tournaments" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] var id: String = Store.randomId() var event: String? @@ -1897,13 +1898,13 @@ defer { DataStore.shared.tournaments.writeChangeAndInsertOnServer(instance: self) for teamRegistration in self.unsortedTeams() { - try teamRegistration.insertOnServer() + teamRegistration.insertOnServer() } for groupStage in self.groupStages() { - try groupStage.insertOnServer() + groupStage.insertOnServer() } for round in self.allRounds() { - try round.insertOnServer() + round.insertOnServer() } } diff --git a/PadelClub/Data/TournamentStore.swift b/PadelClub/Data/TournamentStore.swift index 8012a2b..7a73ad1 100644 --- a/PadelClub/Data/TournamentStore.swift +++ b/PadelClub/Data/TournamentStore.swift @@ -44,9 +44,9 @@ class TournamentStore: Store, ObservableObject { #endif self.groupStages = self.registerCollection(synchronized: synchronized, indexed: indexed) + self.rounds = self.registerCollection(synchronized: synchronized, indexed: indexed) self.teamRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed) self.playerRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed) - self.rounds = self.registerCollection(synchronized: synchronized, indexed: indexed) self.matches = self.registerCollection(synchronized: synchronized, indexed: indexed) self.teamScores = self.registerCollection(synchronized: synchronized, indexed: indexed) self.matchSchedulers = self.registerCollection(synchronized: false, indexed: indexed) diff --git a/PadelClub/Data/User.swift b/PadelClub/Data/User.swift index 429e1c0..18c53c4 100644 --- a/PadelClub/Data/User.swift +++ b/PadelClub/Data/User.swift @@ -20,9 +20,8 @@ class User: ModelObject, UserBase, Storable { static func resourceName() -> String { "users" } static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] } static func filterByStoreIdentifier() -> Bool { return false } + static var relationshipNames: [String] = [] -// func deleteDependencies() throws { } - public var id: String = Store.randomId() public var username: String public var email: String diff --git a/PadelClub/Views/Tournament/Subscription/Purchase.swift b/PadelClub/Views/Tournament/Subscription/Purchase.swift index f0e45c7..5faafa6 100644 --- a/PadelClub/Views/Tournament/Subscription/Purchase.swift +++ b/PadelClub/Views/Tournament/Subscription/Purchase.swift @@ -12,7 +12,8 @@ class Purchase: ModelObject, Storable { static func resourceName() -> String { return "purchases" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } - + static var relationshipNames: [String] = [] + var id: String = Store.randomId() var user: String