112 lines
2.4 KiB
Go
112 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: users.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const insertUser = `-- name: InsertUser :one
|
|
INSERT INTO user_auth (username, email, password_hash)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, username, email, password_hash, created_at, updated_at
|
|
`
|
|
|
|
type InsertUserParams struct {
|
|
Username string
|
|
Email string
|
|
PasswordHash string
|
|
}
|
|
|
|
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (UserAuth, error) {
|
|
row := q.db.QueryRowContext(ctx, insertUser, arg.Username, arg.Email, arg.PasswordHash)
|
|
var i UserAuth
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const patchUser = `-- name: PatchUser :one
|
|
UPDATE user_auth
|
|
SET username = COALESCE($1, username),
|
|
email = COALESCE($2, email),
|
|
password_hash = COALESCE($3, password_hash)
|
|
WHERE id = $4
|
|
RETURNING id, username, email, password_hash, created_at, updated_at
|
|
`
|
|
|
|
type PatchUserParams struct {
|
|
Username sql.NullString
|
|
Email sql.NullString
|
|
PasswordHash sql.NullString
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) PatchUser(ctx context.Context, arg PatchUserParams) (UserAuth, error) {
|
|
row := q.db.QueryRowContext(ctx, patchUser,
|
|
arg.Username,
|
|
arg.Email,
|
|
arg.PasswordHash,
|
|
arg.ID,
|
|
)
|
|
var i UserAuth
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const selectUserById = `-- name: SelectUserById :one
|
|
SELECT id, username, email, password_hash, created_at, updated_at
|
|
FROM user_auth
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) SelectUserById(ctx context.Context, id string) (UserAuth, error) {
|
|
row := q.db.QueryRowContext(ctx, selectUserById, id)
|
|
var i UserAuth
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const selectUserByUsername = `-- name: SelectUserByUsername :one
|
|
SELECT id, username, email, password_hash, created_at, updated_at
|
|
FROM user_auth
|
|
WHERE username = $1
|
|
`
|
|
|
|
func (q *Queries) SelectUserByUsername(ctx context.Context, username string) (UserAuth, error) {
|
|
row := q.db.QueryRowContext(ctx, selectUserByUsername, username)
|
|
var i UserAuth
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|