feat: init commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetAppState(db *gorm.DB) (AppState, error) {
|
||||
var state AppState
|
||||
|
||||
return state, db.First(&state).Error
|
||||
}
|
||||
|
||||
func GetFiles(db *gorm.DB) ([]Files, error) {
|
||||
var files []Files
|
||||
|
||||
return files, db.Find(&files).Error
|
||||
}
|
||||
|
||||
func RegisterFile(db *gorm.DB, category, fullPath string) error {
|
||||
file := Files{
|
||||
Mode: category,
|
||||
Filename: filepath.Base(fullPath),
|
||||
Filepath: fullPath,
|
||||
}
|
||||
|
||||
return db.Create(&file).Error
|
||||
}
|
||||
Reference in New Issue
Block a user