Files
mantrae/server/internal/store/queries/entry_points.sql
2025-07-31 00:37:57 +02:00

75 lines
1.1 KiB
SQL

-- name: CreateEntryPoint :one
INSERT INTO
entry_points (
profile_id,
name,
address,
is_default,
created_at,
updated_at
)
VALUES
(?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING *;
-- name: GetEntryPoint :one
SELECT
*
FROM
entry_points
WHERE
id = ?;
-- name: GetDefaultEntryPoint :one
SELECT
*
FROM
entry_points
WHERE
is_default = TRUE
LIMIT
1;
-- name: UnsetDefaultEntryPoint :exec
UPDATE entry_points
SET
is_default = FALSE
WHERE
is_default = TRUE;
-- name: ListEntryPoints :many
SELECT
*
FROM
entry_points
WHERE
profile_id = sqlc.arg ('profile_id')
ORDER BY
created_at DESC
LIMIT
COALESCE(CAST(sqlc.narg ('limit') AS INTEGER), -1)
OFFSET
COALESCE(CAST(sqlc.narg ('offset') AS INTEGER), 0);
-- name: CountEntryPoints :one
SELECT
COUNT(*)
FROM
entry_points
WHERE
profile_id = ?;
-- name: UpdateEntryPoint :one
UPDATE entry_points
SET
name = ?,
address = ?,
is_default = ?,
updated_at = CURRENT_TIMESTAMP
WHERE
id = ? RETURNING *;
-- name: DeleteEntryPointByID :exec
DELETE FROM entry_points
WHERE
id = ?;