package dao

import "time"

type Version struct {
	ID      int
	Host    string
	Content string
	// Status    bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

func CreateNewVersion(host, content string) error {
	version := Version{
		Host:    host,
		Content: content,
	}
	return db.Create(&version).Error
}

func ListVersions() ([]Version, error) {
	versions := make([]Version, 0)
	result := db.Order("id desc").Find(&versions)
	return versions, result.Error
}

func GetVersion(id int) (*Version, error) {
	version := new(Version)
	result := db.First(version, id)
	return version, result.Error
}
