//
//  tank
//
//  Import and Playlist Daemon for autoradio project
//
//
//  Copyright (C) 2017-2018 Christian Pointner <equinox@helsinki.at>
//
//  This file is part of tank.
//
//  tank is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  any later version.
//
//  tank is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with tank. If not, see <http://www.gnu.org/licenses/>.
//

package store

func (st *Store) ListFiles(group string) (files Files, err error) {
	err = st.db.Model(&Group{Name: group}).Related(&files).Error
	return
}

func (st *Store) CreateFile(group string, file File) (id uint64, err error) {
	// TODO: implement this
	return 0, ErrNotImplented
}

func (st *Store) GetFile(group string, id uint64) (file File, err error) {
	err = st.db.First(&file, id).Error
	return
}

func (st *Store) UpdateFile(group string, id uint64, file File) (err error) {
	// TODO: implement this
	return ErrNotImplented
}

func (st *Store) DeleteFile(group string, id uint64) (err error) {
	// TODO: remove file from directory (using callback??)
	return st.db.Delete(&File{ID: id}).Error
}