// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: users.sql package db import ( "context" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" ) const createAuthMethod = `-- name: CreateAuthMethod :exec INSERT INTO auth_method (user_id, type, value) VALUES ($1, $2, $3) ` type CreateAuthMethodParams struct { UserID uuid.UUID `json:"user_id"` Type AuthType `json:"type"` Value string `json:"value"` } func (q *Queries) CreateAuthMethod(ctx context.Context, arg CreateAuthMethodParams) error { _, err := q.db.Exec(ctx, createAuthMethod, arg.UserID, arg.Type, arg.Value) return err } const createUser = `-- name: CreateUser :one INSERT INTO users (name, email, bio, profile_photo) VALUES($1, $2, $3, $4) RETURNING id, name, email, bio, profile_photo, updated_at, created_at ` type CreateUserParams struct { Name string `json:"name"` Email string `json:"email"` Bio string `json:"bio"` ProfilePhoto pgtype.Text `json:"profile_photo"` } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { row := q.db.QueryRow(ctx, createUser, arg.Name, arg.Email, arg.Bio, arg.ProfilePhoto, ) var i User err := row.Scan( &i.ID, &i.Name, &i.Email, &i.Bio, &i.ProfilePhoto, &i.UpdatedAt, &i.CreatedAt, ) return i, err } 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::text OR u.email = $1) AND a.type = $2::auth_type ` type GetUserAuthValueParams struct { AuthValue string `json:"auth_value"` AuthType AuthType `json:"auth_type"` } type GetUserAuthValueRow struct { UserID uuid.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.AuthValue, arg.AuthType) var i GetUserAuthValueRow err := row.Scan(&i.UserID, &i.AuthValue) return i, err } const getUserById = `-- name: GetUserById :one SELECT id, name, email, bio, profile_photo, updated_at, created_at FROM users u WHERE u.id = $1::uuid ` func (q *Queries) GetUserById(ctx context.Context, userID uuid.UUID) (User, error) { row := q.db.QueryRow(ctx, getUserById, userID) var i User err := row.Scan( &i.ID, &i.Name, &i.Email, &i.Bio, &i.ProfilePhoto, &i.UpdatedAt, &i.CreatedAt, ) return i, err } const updateUser = `-- name: UpdateUser :one UPDATE users SET name = $1::text, email = $2::text, bio = $3::text, profile_photo = $4::text WHERE id = $5::uuid RETURNING id, name, email, bio, profile_photo, updated_at, created_at ` type UpdateUserParams struct { Name string `json:"name"` Email string `json:"email"` Bio string `json:"bio"` Photo string `json:"photo"` ID uuid.UUID `json:"id"` } func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) { row := q.db.QueryRow(ctx, updateUser, arg.Name, arg.Email, arg.Bio, arg.Photo, arg.ID, ) var i User err := row.Scan( &i.ID, &i.Name, &i.Email, &i.Bio, &i.ProfilePhoto, &i.UpdatedAt, &i.CreatedAt, ) return i, err }