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/media_items.go

22 lines
577 B
Go
Raw Normal View History

2021-01-19 20:50:48 +00:00
package db
import (
log "github.com/sirupsen/logrus"
2021-02-02 20:34:10 +00:00
"reichard.io/imagini/graph/model"
2021-01-19 20:50:48 +00:00
)
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) CreateMediaItem (mediaItem *model.MediaItem) error {
2021-01-22 05:00:55 +00:00
log.Info("[db] Creating media item: ", mediaItem.FileName)
2021-01-19 20:50:48 +00:00
err := dbm.db.Create(&mediaItem).Error
2021-02-01 23:24:09 +00:00
return err
2021-01-19 20:50:48 +00:00
}
2021-02-02 20:34:10 +00:00
func (dbm *DBManager) MediaItems(mediaItemFilter *model.MediaItem) ([]model.MediaItem, int64, error) {
var mediaItems []model.MediaItem
2021-02-01 23:24:09 +00:00
var count int64
2021-01-19 20:50:48 +00:00
2021-02-01 23:24:09 +00:00
err := dbm.db.Where(&mediaItemFilter).Find(&mediaItems).Count(&count).Error;
return mediaItems, count, err
2021-01-19 20:50:48 +00:00
}