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

31 lines
784 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-01-18 21:24:28 +00:00
"reichard.io/imagini/internal/models"
2021-01-18 04:56:56 +00:00
)
2021-02-01 23:24:09 +00:00
func (dbm *DBManager) CreateDevice (device *models.Device) error {
2021-01-19 20:50:48 +00:00
log.Info("[db] Creating device: ", device.Name)
2021-01-18 21:16:52 +00:00
device.RefreshKey = uuid.New().String()
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-01 23:24:09 +00:00
func (dbm *DBManager) Device (device *models.Device) (models.Device, error) {
2021-01-18 04:56:56 +00:00
var foundDevice models.Device
var count int64
err := dbm.db.Where(&device).First(&foundDevice).Count(&count).Error
return foundDevice, err
}
2021-02-01 23:24:09 +00:00
func (dbm *DBManager) DeleteDevice (user *models.Device) error {
2021-01-18 04:56:56 +00:00
return nil
}
2021-02-01 23:24:09 +00:00
func (dbm *DBManager) UpdateRefreshToken (device *models.Device, refreshToken string) error {
2021-01-18 04:56:56 +00:00
return nil
}