package psql import ( "git.nix13.pw/scuroneko/laniakea" "github.com/vinovest/sqlx" ) type AIModel struct { ID string Key string Name string ContextSize int `db:"context_size"` } type AIRepository struct { db *sqlx.DB } func newAiRepository(db *sqlx.DB) AIRepository { return AIRepository{db} } func NewAIRepository(db *laniakea.DatabaseContext) AIRepository { return newAiRepository(db.PostgresSQL) } func (rep AIRepository) GetModel(id string) (AIModel, error) { model := AIModel{} err := rep.db.Get(&model, "SELECT * FROM ai_models WHERE id=$1;", id) return model, err } func (rep AIRepository) GetAllModels() ([]AIModel, error) { models := make([]AIModel, 0) err := rep.db.Select(&models, "SELECT * FROM ai_models ORDER BY id;") return models, err }