Files
bracketeer/db/users.sql.go
2026-04-04 13:35:33 -06:00

61 lines
1.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: users.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getUserAuthValue = `-- name: GetUserAuthValue :one
SELECT u.ID as user_id, a.value as auth_value
FROM users u
JOIN auth_method a
ON a.user_id = u.id
WHERE
(u.name = $1 OR u.email = $1)
AND a.type = $2
`
type GetUserAuthValueParams struct {
Name string `json:"name"`
Type AuthType `json:"type"`
}
type GetUserAuthValueRow struct {
UserID pgtype.UUID `json:"user_id"`
AuthValue string `json:"auth_value"`
}
func (q *Queries) GetUserAuthValue(ctx context.Context, arg GetUserAuthValueParams) (GetUserAuthValueRow, error) {
row := q.db.QueryRow(ctx, getUserAuthValue, arg.Name, arg.Type)
var i GetUserAuthValueRow
err := row.Scan(&i.UserID, &i.AuthValue)
return i, err
}
const getUserFromId = `-- name: GetUserFromId :one
SELECT id, name, email, bio, profile_photo, updated_at, created_at
FROM users u
WHERE u.id = $1
`
func (q *Queries) GetUserFromId(ctx context.Context, id pgtype.UUID) (User, error) {
row := q.db.QueryRow(ctx, getUserFromId, id)
var i User
err := row.Scan(
&i.ID,
&i.Name,
&i.Email,
&i.Bio,
&i.ProfilePhoto,
&i.UpdatedAt,
&i.CreatedAt,
)
return i, err
}