// Code generated by sqlc. DO NOT EDIT. // source: user_account.sql package db import ( "context" "time" "github.com/google/uuid" ) const createAccessToken = `-- name: CreateAccessToken :one INSERT INTO access_token (token, user_id, expires_at, created_at) VALUES ($1, $2, $3, $4) RETURNING token, user_id, expires_at, created_at ` type CreateAccessTokenParams struct { Token string `json:"token"` UserID uuid.UUID `json:"user_id"` ExpiresAt time.Time `json:"expires_at"` CreatedAt time.Time `json:"created_at"` } func (q *Queries) CreateAccessToken(ctx context.Context, arg CreateAccessTokenParams) (AccessToken, error) { row := q.db.QueryRowContext(ctx, createAccessToken, arg.Token, arg.UserID, arg.ExpiresAt, arg.CreatedAt, ) var i AccessToken err := row.Scan( &i.Token, &i.UserID, &i.ExpiresAt, &i.CreatedAt, ) return i, err } const createUserAccount = `-- name: CreateUserAccount :one INSERT INTO user_account (created_at, fullname, username, email, password_hash) VALUES ($1, $2, $3, $4, $5) RETURNING user_id, created_at, fullname, username, email, password_hash, avatar_url ` type CreateUserAccountParams struct { CreatedAt time.Time `json:"created_at"` Fullname string `json:"fullname"` Username string `json:"username"` Email string `json:"email"` PasswordHash string `json:"password_hash"` } func (q *Queries) CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error) { row := q.db.QueryRowContext(ctx, createUserAccount, arg.CreatedAt, arg.Fullname, arg.Username, arg.Email, arg.PasswordHash, ) var i UserAccount err := row.Scan( &i.UserID, &i.CreatedAt, &i.Fullname, &i.Username, &i.Email, &i.PasswordHash, &i.AvatarUrl, ) return i, err } const deleteAccessToken = `-- name: DeleteAccessToken :exec DELETE FROM access_token WHERE token = $1 ` func (q *Queries) DeleteAccessToken(ctx context.Context, token string) error { _, err := q.db.ExecContext(ctx, deleteAccessToken, token) return err } const getAccessToken = `-- name: GetAccessToken :one SELECT token, user_id, expires_at, created_at FROM access_token WHERE token = $1 ` func (q *Queries) GetAccessToken(ctx context.Context, token string) (AccessToken, error) { row := q.db.QueryRowContext(ctx, getAccessToken, token) var i AccessToken err := row.Scan( &i.Token, &i.UserID, &i.ExpiresAt, &i.CreatedAt, ) return i, err } const getUserAccountByID = `-- name: GetUserAccountByID :one SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account WHERE user_id = $1 ` func (q *Queries) GetUserAccountByID(ctx context.Context, userID uuid.UUID) (UserAccount, error) { row := q.db.QueryRowContext(ctx, getUserAccountByID, userID) var i UserAccount err := row.Scan( &i.UserID, &i.CreatedAt, &i.Fullname, &i.Username, &i.Email, &i.PasswordHash, &i.AvatarUrl, ) return i, err } const getUserAccountByUsername = `-- name: GetUserAccountByUsername :one SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account WHERE username = $1 ` func (q *Queries) GetUserAccountByUsername(ctx context.Context, username string) (UserAccount, error) { row := q.db.QueryRowContext(ctx, getUserAccountByUsername, username) var i UserAccount err := row.Scan( &i.UserID, &i.CreatedAt, &i.Fullname, &i.Username, &i.Email, &i.PasswordHash, &i.AvatarUrl, ) return i, err } const getUserAccounts = `-- name: GetUserAccounts :many SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account ` func (q *Queries) GetUserAccounts(ctx context.Context) ([]UserAccount, error) { rows, err := q.db.QueryContext(ctx, getUserAccounts) if err != nil { return nil, err } defer rows.Close() var items []UserAccount for rows.Next() { var i UserAccount if err := rows.Scan( &i.UserID, &i.CreatedAt, &i.Fullname, &i.Username, &i.Email, &i.PasswordHash, &i.AvatarUrl, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const hasAnyUserAccount = `-- name: HasAnyUserAccount :one SELECT EXISTS (SELECT user_id, created_at, fullname, username, email, password_hash, avatar_url FROM user_account LIMIT 1) ` func (q *Queries) HasAnyUserAccount(ctx context.Context) (bool, error) { row := q.db.QueryRowContext(ctx, hasAnyUserAccount) var exists bool err := row.Scan(&exists) return exists, err }