Files
mantrae/internal/db/entry_points.sql.go
d34dscene 040c1ffc35 oof
2025-06-17 00:49:55 +02:00

199 lines
3.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: entry_points.sql
package db
import (
"context"
)
const countEntryPoints = `-- name: CountEntryPoints :one
SELECT
COUNT(*)
FROM
entry_points
`
func (q *Queries) CountEntryPoints(ctx context.Context) (int64, error) {
row := q.queryRow(ctx, q.countEntryPointsStmt, countEntryPoints)
var count int64
err := row.Scan(&count)
return count, err
}
const createEntryPoint = `-- name: CreateEntryPoint :one
INSERT INTO
entry_points (
id,
profile_id,
name,
address,
is_default,
created_at,
updated_at
)
VALUES
(
?,
?,
?,
?,
?,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
) RETURNING id, profile_id, name, address, is_default, created_at, updated_at
`
type CreateEntryPointParams struct {
ID int64 `json:"id"`
ProfileID int64 `json:"profileId"`
Name string `json:"name"`
Address string `json:"address"`
IsDefault bool `json:"isDefault"`
}
func (q *Queries) CreateEntryPoint(ctx context.Context, arg CreateEntryPointParams) (EntryPoint, error) {
row := q.queryRow(ctx, q.createEntryPointStmt, createEntryPoint,
arg.ID,
arg.ProfileID,
arg.Name,
arg.Address,
arg.IsDefault,
)
var i EntryPoint
err := row.Scan(
&i.ID,
&i.ProfileID,
&i.Name,
&i.Address,
&i.IsDefault,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const deleteEntryPoint = `-- name: DeleteEntryPoint :exec
DELETE FROM entry_points
WHERE
id = ?
`
func (q *Queries) DeleteEntryPoint(ctx context.Context, id int64) error {
_, err := q.exec(ctx, q.deleteEntryPointStmt, deleteEntryPoint, id)
return err
}
const getEntryPoint = `-- name: GetEntryPoint :one
SELECT
id, profile_id, name, address, is_default, created_at, updated_at
FROM
entry_points
WHERE
id = ?
`
func (q *Queries) GetEntryPoint(ctx context.Context, id int64) (EntryPoint, error) {
row := q.queryRow(ctx, q.getEntryPointStmt, getEntryPoint, id)
var i EntryPoint
err := row.Scan(
&i.ID,
&i.ProfileID,
&i.Name,
&i.Address,
&i.IsDefault,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const listEntryPoints = `-- name: ListEntryPoints :many
SELECT
id, profile_id, name, address, is_default, created_at, updated_at
FROM
entry_points
ORDER BY
name
LIMIT
?
OFFSET
?
`
type ListEntryPointsParams struct {
Limit int64 `json:"limit"`
Offset int64 `json:"offset"`
}
func (q *Queries) ListEntryPoints(ctx context.Context, arg ListEntryPointsParams) ([]EntryPoint, error) {
rows, err := q.query(ctx, q.listEntryPointsStmt, listEntryPoints, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []EntryPoint
for rows.Next() {
var i EntryPoint
if err := rows.Scan(
&i.ID,
&i.ProfileID,
&i.Name,
&i.Address,
&i.IsDefault,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateEntryPoint = `-- name: UpdateEntryPoint :one
UPDATE entry_points
SET
name = ?,
address = ?,
is_default = ?,
updated_at = CURRENT_TIMESTAMP
WHERE
id = ? RETURNING id, profile_id, name, address, is_default, created_at, updated_at
`
type UpdateEntryPointParams struct {
Name string `json:"name"`
Address string `json:"address"`
IsDefault bool `json:"isDefault"`
ID int64 `json:"id"`
}
func (q *Queries) UpdateEntryPoint(ctx context.Context, arg UpdateEntryPointParams) (EntryPoint, error) {
row := q.queryRow(ctx, q.updateEntryPointStmt, updateEntryPoint,
arg.Name,
arg.Address,
arg.IsDefault,
arg.ID,
)
var i EntryPoint
err := row.Scan(
&i.ID,
&i.ProfileID,
&i.Name,
&i.Address,
&i.IsDefault,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}