forked from mtusi2026/mtusi2026lab2
101 lines
2.0 KiB
Go
101 lines
2.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: users.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (username, display_name, password_hash)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, username, display_name, created_at, password_hash
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
Username string
|
|
DisplayName string
|
|
PasswordHash string
|
|
}
|
|
|
|
type CreateUserRow struct {
|
|
ID uuid.UUID
|
|
Username string
|
|
DisplayName string
|
|
CreatedAt time.Time
|
|
PasswordHash string
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error) {
|
|
row := q.db.QueryRow(ctx, createUser, arg.Username, arg.DisplayName, arg.PasswordHash)
|
|
var i CreateUserRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.DisplayName,
|
|
&i.CreatedAt,
|
|
&i.PasswordHash,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByID = `-- name: GetUserByID :one
|
|
SELECT id, username, display_name, created_at, password_hash
|
|
FROM users
|
|
WHERE id = $1
|
|
`
|
|
|
|
type GetUserByIDRow struct {
|
|
ID uuid.UUID
|
|
Username string
|
|
DisplayName string
|
|
CreatedAt time.Time
|
|
PasswordHash string
|
|
}
|
|
|
|
func (q *Queries) GetUserByID(ctx context.Context, id uuid.UUID) (GetUserByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserByID, id)
|
|
var i GetUserByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.DisplayName,
|
|
&i.CreatedAt,
|
|
&i.PasswordHash,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByUsername = `-- name: GetUserByUsername :one
|
|
SELECT id, username, display_name, created_at, password_hash
|
|
FROM users
|
|
WHERE username = $1
|
|
`
|
|
|
|
type GetUserByUsernameRow struct {
|
|
ID uuid.UUID
|
|
Username string
|
|
DisplayName string
|
|
CreatedAt time.Time
|
|
PasswordHash string
|
|
}
|
|
|
|
func (q *Queries) GetUserByUsername(ctx context.Context, username string) (GetUserByUsernameRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserByUsername, username)
|
|
var i GetUserByUsernameRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.DisplayName,
|
|
&i.CreatedAt,
|
|
&i.PasswordHash,
|
|
)
|
|
return i, err
|
|
}
|