This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/internal/db/devices.go

32 lines
804 B
Go
Raw Normal View History

2021-01-18 04:56:56 +00:00
package db
import (
2021-01-18 21:16:52 +00:00
"github.com/google/uuid"
2021-01-18 04:56:56 +00:00
log "github.com/sirupsen/logrus"
2021-02-02 20:34:10 +00:00
"reichard.io/imagini/graph/model"
2021-01-18 04:56:56 +00:00
)
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) CreateDevice (device *model.Device) error {
2021-01-19 20:50:48 +00:00
log.Info("[db] Creating device: ", device.Name)
2021-02-02 20:34:10 +00:00
refreshKey := uuid.New().String()
device.RefreshKey = &refreshKey
2021-01-18 21:16:52 +00:00
err := dbm.db.Create(&device).Error
2021-02-01 23:24:09 +00:00
return err
2021-01-18 04:56:56 +00:00
}
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) Device (device *model.Device) (model.Device, error) {
var foundDevice model.Device
2021-01-18 04:56:56 +00:00
var count int64
err := dbm.db.Where(&device).First(&foundDevice).Count(&count).Error
return foundDevice, err
}
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) DeleteDevice (user *model.Device) error {
2021-01-18 04:56:56 +00:00
return nil
}
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) UpdateRefreshToken (device *model.Device, refreshToken string) error {
2021-01-18 04:56:56 +00:00
return nil
}