// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.26.0 // source: users.sql package db import ( "context" "github.com/google/uuid" ) const createUser = `-- name: CreateUser :one INSERT INTO users( email, created, modified, display_name, password_hash, root, home ) VALUES ( $1, NOW(), NOW(), $2, $3, $4, $5 ) RETURNING id, email, created, modified, display_name, password_hash, deleted, root, home ` type CreateUserParams struct { Email string DisplayName string PasswordHash string Root uuid.UUID Home uuid.UUID } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { row := q.db.QueryRow(ctx, createUser, arg.Email, arg.DisplayName, arg.PasswordHash, arg.Root, arg.Home, ) var i User err := row.Scan( &i.ID, &i.Email, &i.Created, &i.Modified, &i.DisplayName, &i.PasswordHash, &i.Deleted, &i.Root, &i.Home, ) return i, err } const listUsers = `-- name: ListUsers :many SELECT id, email, created, modified, display_name, password_hash, deleted, root, home from users WHERE deleted IS NULL ` func (q *Queries) ListUsers(ctx context.Context) ([]User, error) { rows, err := q.db.Query(ctx, listUsers) if err != nil { return nil, err } defer rows.Close() var items []User for rows.Next() { var i User if err := rows.Scan( &i.ID, &i.Email, &i.Created, &i.Modified, &i.DisplayName, &i.PasswordHash, &i.Deleted, &i.Root, &i.Home, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateUserDisplayName = `-- name: UpdateUserDisplayName :exec UPDATE users SET display_name = $1, modified = NOW() WHERE id = $2 ` type UpdateUserDisplayNameParams struct { DisplayName string ID int32 } func (q *Queries) UpdateUserDisplayName(ctx context.Context, arg UpdateUserDisplayNameParams) error { _, err := q.db.Exec(ctx, updateUserDisplayName, arg.DisplayName, arg.ID) return err } const updateUserHome = `-- name: UpdateUserHome :exec UPDATE users SET home = $1, modified = NOW() WHERE id = $2 ` type UpdateUserHomeParams struct { Home uuid.UUID ID int32 } func (q *Queries) UpdateUserHome(ctx context.Context, arg UpdateUserHomeParams) error { _, err := q.db.Exec(ctx, updateUserHome, arg.Home, arg.ID) return err } const updateUserPasswordHash = `-- name: UpdateUserPasswordHash :exec UPDATE users SET password_hash = $1, modified = NOW() WHERE id = $2 ` type UpdateUserPasswordHashParams struct { PasswordHash string ID int32 } func (q *Queries) UpdateUserPasswordHash(ctx context.Context, arg UpdateUserPasswordHashParams) error { _, err := q.db.Exec(ctx, updateUserPasswordHash, arg.PasswordHash, arg.ID) return err } const updateUserRoot = `-- name: UpdateUserRoot :exec UPDATE users SET root = $1, modified = NOW() WHERE id = $2 ` type UpdateUserRootParams struct { Root uuid.UUID ID int32 } func (q *Queries) UpdateUserRoot(ctx context.Context, arg UpdateUserRootParams) error { _, err := q.db.Exec(ctx, updateUserRoot, arg.Root, arg.ID) return err } const userByEmail = `-- name: UserByEmail :one SELECT id, email, created, modified, display_name, password_hash, deleted, root, home from users WHERE email = $1 ` func (q *Queries) UserByEmail(ctx context.Context, email string) (User, error) { row := q.db.QueryRow(ctx, userByEmail, email) var i User err := row.Scan( &i.ID, &i.Email, &i.Created, &i.Modified, &i.DisplayName, &i.PasswordHash, &i.Deleted, &i.Root, &i.Home, ) return i, err } const userByID = `-- name: UserByID :one SELECT id, email, created, modified, display_name, password_hash, deleted, root, home from users WHERE id = $1 ` func (q *Queries) UserByID(ctx context.Context, id int32) (User, error) { row := q.db.QueryRow(ctx, userByID, id) var i User err := row.Scan( &i.ID, &i.Email, &i.Created, &i.Modified, &i.DisplayName, &i.PasswordHash, &i.Deleted, &i.Root, &i.Home, ) return i, err }