Categoriecontroller added

This commit is contained in:
2023-11-19 12:27:53 +01:00
parent 57b217793d
commit fa3132f61d
8 changed files with 79 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
package models
import "time"
import (
"gorm.io/gorm"
"time"
)
type Section struct {
ID string
@@ -9,3 +12,12 @@ type Section struct {
UpdatedAt time.Time
Categories []Category
}
func GetSection(db *gorm.DB) ([]Section, error) {
var sections []Section
err := db.Debug().Model(&Section{}).Order("created_at desc").Find(&sections).Error
if err != nil {
return nil, err
}
return sections, nil
}