prepare changes
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2024-11-11 12:43:29 +01:00
parent f2f16c811a
commit 3d68aa0e61
3 changed files with 28 additions and 100 deletions

View File

@@ -70,5 +70,27 @@ func (self *DatabaseHandle) GetDeviceByLabelAndApplication(applicationLabel stri
return &device, nil
}
func (self *DatabaseHandle) GetDeviceByLabel(deviceLabel string) (*Device, error) {
if ! self.initialized {
err := fmt.Errorf("Database connection not initialized")
return nil, err
}
var device Device
result := self.dbh.
Preload("Application").
Preload("DeviceType").
Where("devices.label = ?", deviceLabel).
First(&device)
if result.Error != nil {
err := fmt.Errorf("Query failed: %s", result.Error)
return nil, err
}
return &device, nil
}