24 lines
402 B
Go
24 lines
402 B
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
type Section struct {
|
|
ID string
|
|
Name string
|
|
CreatedAt time.Time
|
|
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
|
|
}
|