- sqlc.yaml: overrides citext→string and uuid→uuid.UUID (Pattern 10, Pitfall 3) - users.sql: InsertUser :one and GetUserByEmail :one - sessions.sql: InsertSession :exec, GetSessionWithUser :one (expires_at > now() per D-07), DeleteSession :exec, DeleteSessionsByUser :exec, ExtendSession :exec - sqlc generate produces Email string (not pgtype.Text) and uuid.UUID in bindings - go build ./internal/db/... exits 0
9 lines
257 B
SQL
9 lines
257 B
SQL
-- name: InsertUser :one
|
|
INSERT INTO users (email, password_hash)
|
|
VALUES ($1, $2)
|
|
RETURNING id, email, password_hash, created_at, updated_at;
|
|
|
|
-- name: GetUserByEmail :one
|
|
SELECT id, email, password_hash, created_at, updated_at
|
|
FROM users
|
|
WHERE email = $1;
|