feat: implement get session by user

This commit is contained in:
2026-01-02 23:00:13 +07:00
parent f7a1044343
commit d864027c31
8 changed files with 277 additions and 198 deletions

View File

@@ -1,34 +1,6 @@
-- name: CreateIdentifier :one
INSERT INTO identifiers (slug)
VALUES ($1)
RETURNING id, slug, created_at, updated_at;
-- name: GetIdentifierById :one
SELECT id, slug, created_at, updated_at
FROM identifiers
WHERE id = $1;
-- name: GetIdentifierBySlug :one
SELECT id, slug, created_at, updated_at
FROM identifiers
WHERE slug = $1;
-- name: ListIdentifiers :many
SELECT id, slug, created_at, updated_at
FROM identifiers
ORDER BY created_at DESC
LIMIT $1 OFFSET $2;
-- name: DeleteIdentifier :exec
DELETE FROM identifiers
WHERE id = $1;
-- name: UpdateIdentifierSlug :one
UPDATE identifiers
SET slug = $2, updated_at = NOW()
WHERE id = $1
RETURNING id, slug, created_at, updated_at;
-- name: CountIdentifiers :one
SELECT COUNT(*) FROM identifiers;
-- name: UserExistsByIdentifier :one
SELECT EXISTS (
SELECT 1
FROM public."user"
WHERE identifier = $1
) AS exists;