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(&sections).Error
	if err != nil {
		return nil, err
	}
	return sections, nil
}

func GetSectionByID(db *gorm.DB, id string) (Section, error) {
	var section Section
	err := db.Debug().Model(&Section{}).Where("id = ?", id).Find(&section).Error
	if err != nil {
		
	}
	return section, nil
}
