Categoriecontroller added
This commit is contained in:
@@ -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(§ions).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sections, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user