feat: add new features such as database watchdog
This commit is contained in:
@@ -1,29 +1,21 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetAppState(db *gorm.DB) (AppState, error) {
|
||||
var state AppState
|
||||
func GetState(db *gorm.DB) (State, error) {
|
||||
var state State
|
||||
|
||||
return state, db.First(&state).Error
|
||||
}
|
||||
|
||||
func GetFiles(db *gorm.DB) ([]Files, error) {
|
||||
var files []Files
|
||||
func GetFiles(db *gorm.DB) ([]File, error) {
|
||||
var files []File
|
||||
|
||||
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
|
||||
func RegisterFile(db *gorm.DB, f File) error {
|
||||
return db.Create(&f).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user