// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.27.0
// source: user.sql

package postgres

import (
	"context"
)

const createUser = `-- name: CreateUser :one
INSERT INTO "user"
    (username, password, name, email, auth_token, authorized, admin, organization)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, username, password, name, email, auth_token, authorized, admin, organization
`

type CreateUserParams struct {
	Username     string `db:"username" json:"username"`
	Password     string `db:"password" json:"password"`
	Name         string `db:"name" json:"name"`
	Email        string `db:"email" json:"email"`
	AuthToken    string `db:"auth_token" json:"auth_token"`
	Authorized   int64  `db:"authorized" json:"authorized"`
	Admin        int64  `db:"admin" json:"admin"`
	Organization int64  `db:"organization" json:"organization"`
}

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
	row := q.db.QueryRowContext(ctx, createUser,
		arg.Username,
		arg.Password,
		arg.Name,
		arg.Email,
		arg.AuthToken,
		arg.Authorized,
		arg.Admin,
		arg.Organization,
	)
	var i User
	err := row.Scan(
		&i.Identifier,
		&i.Username,
		&i.Password,
		&i.Name,
		&i.Email,
		&i.AuthToken,
		&i.Authorized,
		&i.Admin,
		&i.Organization,
	)
	return i, err
}

const findUserByUsername = `-- name: FindUserByUsername :one
SELECT id, username, password, name, email, auth_token, authorized, admin, organization FROM "user"
WHERE username = $1
`

func (q *Queries) FindUserByUsername(ctx context.Context, username string) (User, error) {
	row := q.db.QueryRowContext(ctx, findUserByUsername, username)
	var i User
	err := row.Scan(
		&i.Identifier,
		&i.Username,
		&i.Password,
		&i.Name,
		&i.Email,
		&i.AuthToken,
		&i.Authorized,
		&i.Admin,
		&i.Organization,
	)
	return i, err
}
