mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2025-12-17 20:34:36 -06:00
232 lines
4.7 KiB
Go
232 lines
4.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: entry_points.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const countEntryPoints = `-- name: CountEntryPoints :one
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
entry_points
|
|
WHERE
|
|
profile_id = ?
|
|
`
|
|
|
|
func (q *Queries) CountEntryPoints(ctx context.Context, profileID int64) (int64, error) {
|
|
row := q.queryRow(ctx, q.countEntryPointsStmt, countEntryPoints, profileID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createEntryPoint = `-- name: CreateEntryPoint :one
|
|
INSERT INTO
|
|
entry_points (
|
|
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 {
|
|
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.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 deleteEntryPointByID = `-- name: DeleteEntryPointByID :exec
|
|
DELETE FROM entry_points
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteEntryPointByID(ctx context.Context, id int64) error {
|
|
_, err := q.exec(ctx, q.deleteEntryPointByIDStmt, deleteEntryPointByID, id)
|
|
return err
|
|
}
|
|
|
|
const getDefaultEntryPoint = `-- name: GetDefaultEntryPoint :one
|
|
SELECT
|
|
id, profile_id, name, address, is_default, created_at, updated_at
|
|
FROM
|
|
entry_points
|
|
WHERE
|
|
is_default = TRUE
|
|
LIMIT
|
|
1
|
|
`
|
|
|
|
func (q *Queries) GetDefaultEntryPoint(ctx context.Context) (EntryPoint, error) {
|
|
row := q.queryRow(ctx, q.getDefaultEntryPointStmt, getDefaultEntryPoint)
|
|
var i EntryPoint
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Name,
|
|
&i.Address,
|
|
&i.IsDefault,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, 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
|
|
WHERE
|
|
profile_id = ?1
|
|
ORDER BY
|
|
created_at DESC
|
|
LIMIT
|
|
COALESCE(CAST(?3 AS INTEGER), -1)
|
|
OFFSET
|
|
COALESCE(CAST(?2 AS INTEGER), 0)
|
|
`
|
|
|
|
type ListEntryPointsParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Offset *int64 `json:"offset"`
|
|
Limit *int64 `json:"limit"`
|
|
}
|
|
|
|
func (q *Queries) ListEntryPoints(ctx context.Context, arg ListEntryPointsParams) ([]EntryPoint, error) {
|
|
rows, err := q.query(ctx, q.listEntryPointsStmt, listEntryPoints, arg.ProfileID, arg.Offset, arg.Limit)
|
|
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 unsetDefaultEntryPoint = `-- name: UnsetDefaultEntryPoint :exec
|
|
UPDATE entry_points
|
|
SET
|
|
is_default = FALSE
|
|
WHERE
|
|
is_default = TRUE
|
|
`
|
|
|
|
func (q *Queries) UnsetDefaultEntryPoint(ctx context.Context) error {
|
|
_, err := q.exec(ctx, q.unsetDefaultEntryPointStmt, unsetDefaultEntryPoint)
|
|
return err
|
|
}
|
|
|
|
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
|
|
}
|