package db

import "gorm.io/gorm"

func GetMachines(dbConn *gorm.DB) *[]Machine {
	var machines []Machine

	dbConn.Order("name").Find(&machines)

	return &machines
}

func GetMachine(dbConn *gorm.DB, id int) (*Machine, error) {
	var machine Machine

	result := dbConn.Order("name").Where("id = ?", id).First(&machine)
	if result.Error != nil {
		return nil, result.Error
	}

	return &machine, nil
}
