Upserting races and circuits

This commit is contained in:
christalib 2019-11-02 11:28:35 +01:00
parent ca14f109fe
commit 800cac83ca

View file

@ -114,9 +114,10 @@ func GetSeasonFromErgast(year string) {
URL: race.URL, URL: race.URL,
} }
tx.Assign(circuit).FirstOrCreate(&circuit) tx.Where(Circuit{Name: circuit.Name}).Assign(Circuit{}).FirstOrCreate(&circuit)
tx.Assign(race).FirstOrCreate(&race) tx.Where(Race{RaceName: race.RaceName}).Assign(Race{}).FirstOrCreate(&race)
} }
defer tx.Close() defer tx.Close()
} }