Created
November 8, 2021 22:21
-
-
Save KevinStrong/ecae3b89d5343f81462972421ea2b42d to your computer and use it in GitHub Desktop.
Golang code that uses gorm to read events and kiosks from the database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func getEvent(eventID uint, db *gorm.DB) (Event, error) { | |
| event := Event{ Model: gorm.Model{ID: eventID}} | |
| result := db.Preload("Kiosks").First(&event) | |
| return event, result.Error | |
| } | |
| func getKiosk( kioskID uint, db *gorm.DB) (Kiosk, error) { | |
| kiosk := Kiosk{ Model: gorm.Model{ID: kioskID}} | |
| result := db.Preload("Events").First(&kiosk) | |
| return kiosk, result.Error | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment