df/bff/db/query/account.sql
itsscb d0098a76f4 rf/removes account_info out of accounts
and removes folder /bff/api because all features are implemented with
grpc and grpc-gateway
2023-10-23 22:28:30 +02:00

47 lines
1.0 KiB
SQL

-- name: GetAccount :one
SELECT * FROM accounts
WHERE "id" = sqlc.arg(id);
-- name: GetAccountByEmail :one
SELECT * FROM accounts
WHERE "email" = sqlc.arg(email);
-- name: CreateAccount :one
INSERT INTO accounts (
"email",
"passwordhash",
"secret_key"
)
VALUES (
sqlc.arg(email),
sqlc.arg(passwordhash),
sqlc.arg(secret_key)
)
RETURNING *;
-- name: UpdateAccount :one
UPDATE accounts
SET
"email" = COALESCE(sqlc.narg(email), "email"),
"passwordhash" = COALESCE(sqlc.narg(passwordhash), "passwordhash"),
"secret_key" = COALESCE(sqlc.narg(secret_key), "secret_key")
WHERE "id" = sqlc.arg(id)
RETURNING *;
-- name: ListAccounts :many
SELECT * FROM accounts
ORDER BY "email"
LIMIT $1
OFFSET $2;
-- name: VerifyAccountEmail :exec
UPDATE accounts
SET
"email_verified" = sqlc.arg(email_verified),
"email_verified_time" = sqlc.arg(email_verified_time),
"secret_key" = ''
WHERE "id" = sqlc.arg(id);
-- name: DeleteAccount :exec
DELETE FROM accounts
WHERE "id" = sqlc.arg(id);