database changes

This commit is contained in:
2026-02-12 15:09:06 +03:00
parent c5448b14f6
commit 022cf4ba06
18 changed files with 202 additions and 223 deletions

View File

@@ -16,20 +16,20 @@ type AIRepository struct {
db *sqlx.DB
}
func newAiRepository(db *sqlx.DB) *AIRepository {
return &AIRepository{db}
func newAiRepository(db *sqlx.DB) AIRepository {
return AIRepository{db}
}
func NewAIRepository(db *laniakea.DatabaseContext) *AIRepository {
func NewAIRepository(db *laniakea.DatabaseContext) AIRepository {
return newAiRepository(db.PostgresSQL)
}
func (rep *AIRepository) GetModel(id string) (*AIModel, error) {
model := new(AIModel)
err := rep.db.Get(model, "SELECT * FROM ai_models WHERE id=$1;", id)
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)
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
}