Sync gists from database or filesystem (admin panel)

This commit is contained in:
Thomas Miceli
2023-03-19 01:51:25 +01:00
parent be7e9ab385
commit 11b3eed250
4 changed files with 105 additions and 1 deletions

View File

@@ -93,6 +93,15 @@ func GetAllGistsFromUser(fromUser string, currentUserId uint, offset int, sort s
return gists, err
}
func GetAllGistsRows() ([]*Gist, error) {
var gists []*Gist
err := db.Table("gists").
Preload("User").
Find(&gists).Error
return gists, err
}
func (gist *Gist) Create() error {
// avoids foreign key constraint error because the default value in the struct is 0
return db.Omit("forked_id").Create(&gist).Error