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
2021-02-02 15:34:10 -05:00

22 lines
577 B
Go

package db
import (
log "github.com/sirupsen/logrus"
"reichard.io/imagini/graph/model"
)
func (dbm *DBManager) CreateMediaItem (mediaItem *model.MediaItem) error {
log.Info("[db] Creating media item: ", mediaItem.FileName)
err := dbm.db.Create(&mediaItem).Error
return err
}
func (dbm *DBManager) MediaItems(mediaItemFilter *model.MediaItem) ([]model.MediaItem, int64, error) {
var mediaItems []model.MediaItem
var count int64
err := dbm.db.Where(&mediaItemFilter).Find(&mediaItems).Count(&count).Error;
return mediaItems, count, err
}