32 lines
804 B
Go
32 lines
804 B
Go
package db
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"reichard.io/imagini/graph/model"
|
|
)
|
|
|
|
func (dbm *DBManager) CreateDevice (device *model.Device) error {
|
|
log.Info("[db] Creating device: ", device.Name)
|
|
refreshKey := uuid.New().String()
|
|
device.RefreshKey = &refreshKey
|
|
err := dbm.db.Create(&device).Error
|
|
return err
|
|
}
|
|
|
|
func (dbm *DBManager) Device (device *model.Device) (model.Device, error) {
|
|
var foundDevice model.Device
|
|
var count int64
|
|
err := dbm.db.Where(&device).First(&foundDevice).Count(&count).Error
|
|
return foundDevice, err
|
|
}
|
|
|
|
func (dbm *DBManager) DeleteDevice (user *model.Device) error {
|
|
return nil
|
|
}
|
|
|
|
func (dbm *DBManager) UpdateRefreshToken (device *model.Device, refreshToken string) error {
|
|
return nil
|
|
}
|