mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
357 lines
7.6 KiB
Go
357 lines
7.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: models.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const countModels = `-- name: CountModels :one
|
|
SELECT COUNT(*) FROM models
|
|
`
|
|
|
|
func (q *Queries) CountModels(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countModels)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countModelsByType = `-- name: CountModelsByType :one
|
|
SELECT COUNT(*) FROM models WHERE type = $1
|
|
`
|
|
|
|
func (q *Queries) CountModelsByType(ctx context.Context, type_ string) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countModelsByType, type_)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createModel = `-- name: CreateModel :one
|
|
INSERT INTO models (model_id, name, base_url, api_key, client_type, dimensions, type)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7
|
|
)
|
|
RETURNING id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at
|
|
`
|
|
|
|
type CreateModelParams struct {
|
|
ModelID string `json:"model_id"`
|
|
Name pgtype.Text `json:"name"`
|
|
BaseUrl string `json:"base_url"`
|
|
ApiKey string `json:"api_key"`
|
|
ClientType string `json:"client_type"`
|
|
Dimensions pgtype.Int4 `json:"dimensions"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
func (q *Queries) CreateModel(ctx context.Context, arg CreateModelParams) (Model, error) {
|
|
row := q.db.QueryRow(ctx, createModel,
|
|
arg.ModelID,
|
|
arg.Name,
|
|
arg.BaseUrl,
|
|
arg.ApiKey,
|
|
arg.ClientType,
|
|
arg.Dimensions,
|
|
arg.Type,
|
|
)
|
|
var i Model
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteModel = `-- name: DeleteModel :exec
|
|
DELETE FROM models WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteModel(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteModel, id)
|
|
return err
|
|
}
|
|
|
|
const deleteModelByModelID = `-- name: DeleteModelByModelID :exec
|
|
DELETE FROM models WHERE model_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteModelByModelID(ctx context.Context, modelID string) error {
|
|
_, err := q.db.Exec(ctx, deleteModelByModelID, modelID)
|
|
return err
|
|
}
|
|
|
|
const getModelByID = `-- name: GetModelByID :one
|
|
SELECT id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at FROM models WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetModelByID(ctx context.Context, id pgtype.UUID) (Model, error) {
|
|
row := q.db.QueryRow(ctx, getModelByID, id)
|
|
var i Model
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getModelByModelID = `-- name: GetModelByModelID :one
|
|
SELECT id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at FROM models WHERE model_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetModelByModelID(ctx context.Context, modelID string) (Model, error) {
|
|
row := q.db.QueryRow(ctx, getModelByModelID, modelID)
|
|
var i Model
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listModels = `-- name: ListModels :many
|
|
SELECT id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at FROM models
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListModels(ctx context.Context) ([]Model, error) {
|
|
rows, err := q.db.Query(ctx, listModels)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Model
|
|
for rows.Next() {
|
|
var i Model
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listModelsByClientType = `-- name: ListModelsByClientType :many
|
|
SELECT id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at FROM models
|
|
WHERE client_type = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListModelsByClientType(ctx context.Context, clientType string) ([]Model, error) {
|
|
rows, err := q.db.Query(ctx, listModelsByClientType, clientType)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Model
|
|
for rows.Next() {
|
|
var i Model
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listModelsByType = `-- name: ListModelsByType :many
|
|
SELECT id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at FROM models
|
|
WHERE type = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListModelsByType(ctx context.Context, type_ string) ([]Model, error) {
|
|
rows, err := q.db.Query(ctx, listModelsByType, type_)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Model
|
|
for rows.Next() {
|
|
var i Model
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateModel = `-- name: UpdateModel :one
|
|
UPDATE models
|
|
SET
|
|
name = $1,
|
|
base_url = $2,
|
|
api_key = $3,
|
|
client_type = $4,
|
|
dimensions = $5,
|
|
type = $6,
|
|
updated_at = now()
|
|
WHERE id = $7
|
|
RETURNING id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at
|
|
`
|
|
|
|
type UpdateModelParams struct {
|
|
Name pgtype.Text `json:"name"`
|
|
BaseUrl string `json:"base_url"`
|
|
ApiKey string `json:"api_key"`
|
|
ClientType string `json:"client_type"`
|
|
Dimensions pgtype.Int4 `json:"dimensions"`
|
|
Type string `json:"type"`
|
|
ID pgtype.UUID `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateModel(ctx context.Context, arg UpdateModelParams) (Model, error) {
|
|
row := q.db.QueryRow(ctx, updateModel,
|
|
arg.Name,
|
|
arg.BaseUrl,
|
|
arg.ApiKey,
|
|
arg.ClientType,
|
|
arg.Dimensions,
|
|
arg.Type,
|
|
arg.ID,
|
|
)
|
|
var i Model
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateModelByModelID = `-- name: UpdateModelByModelID :one
|
|
UPDATE models
|
|
SET
|
|
name = $1,
|
|
base_url = $2,
|
|
api_key = $3,
|
|
client_type = $4,
|
|
dimensions = $5,
|
|
type = $6,
|
|
updated_at = now()
|
|
WHERE model_id = $7
|
|
RETURNING id, model_id, name, base_url, api_key, client_type, dimensions, type, created_at, updated_at
|
|
`
|
|
|
|
type UpdateModelByModelIDParams struct {
|
|
Name pgtype.Text `json:"name"`
|
|
BaseUrl string `json:"base_url"`
|
|
ApiKey string `json:"api_key"`
|
|
ClientType string `json:"client_type"`
|
|
Dimensions pgtype.Int4 `json:"dimensions"`
|
|
Type string `json:"type"`
|
|
ModelID string `json:"model_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateModelByModelID(ctx context.Context, arg UpdateModelByModelIDParams) (Model, error) {
|
|
row := q.db.QueryRow(ctx, updateModelByModelID,
|
|
arg.Name,
|
|
arg.BaseUrl,
|
|
arg.ApiKey,
|
|
arg.ClientType,
|
|
arg.Dimensions,
|
|
arg.Type,
|
|
arg.ModelID,
|
|
)
|
|
var i Model
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ModelID,
|
|
&i.Name,
|
|
&i.BaseUrl,
|
|
&i.ApiKey,
|
|
&i.ClientType,
|
|
&i.Dimensions,
|
|
&i.Type,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|