taskcafe/internal/db/query/user_account.sql

24 lines
755 B
MySQL
Raw Normal View History

2022-05-06 23:41:52 +02:00
-- name: GetUserAccounts :many
SELECT * FROM user_account;
-- name: GetUserAccountByUsername :one
SELECT * FROM user_account WHERE username = $1;
-- name: GetUserAccountByID :one
SELECT * FROM user_account WHERE user_id = $1;
-- name: HasAnyUserAccount :one
SELECT EXISTS (SELECT * FROM user_account LIMIT 1);
-- name: CreateUserAccount :one
INSERT INTO user_account (created_at, fullname, username, email, password_hash) VALUES ($1, $2, $3, $4, $5) RETURNING *;
-- name: CreateAccessToken :one
INSERT INTO access_token (token, user_id, expires_at, created_at) VALUES ($1, $2, $3, $4) RETURNING *;
-- name: GetAccessToken :one
SELECT * FROM access_token WHERE token = $1;
-- name: DeleteAccessToken :exec
DELETE FROM access_token WHERE token = $1;