// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: users.sql package sqlc import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const countUsers = `-- name: CountUsers :one SELECT COUNT(*)::bigint AS count FROM users ` func (q *Queries) CountUsers(ctx context.Context) (int64, error) { row := q.db.QueryRow(ctx, countUsers) var count int64 err := row.Scan(&count) return count, err } const createUser = `-- name: CreateUser :one INSERT INTO users (username, email, password_hash, role, display_name, avatar_url, is_active, data_root) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8 ) RETURNING id, username, email, password_hash, role, display_name, avatar_url, is_active, data_root, created_at, updated_at, last_login_at ` type CreateUserParams struct { Username string `json:"username"` Email pgtype.Text `json:"email"` PasswordHash string `json:"password_hash"` Role interface{} `json:"role"` DisplayName pgtype.Text `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` IsActive bool `json:"is_active"` DataRoot pgtype.Text `json:"data_root"` } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { row := q.db.QueryRow(ctx, createUser, arg.Username, arg.Email, arg.PasswordHash, arg.Role, arg.DisplayName, arg.AvatarUrl, arg.IsActive, arg.DataRoot, ) var i User err := row.Scan( &i.ID, &i.Username, &i.Email, &i.PasswordHash, &i.Role, &i.DisplayName, &i.AvatarUrl, &i.IsActive, &i.DataRoot, &i.CreatedAt, &i.UpdatedAt, &i.LastLoginAt, ) return i, err } const getUserByUsername = `-- name: GetUserByUsername :one SELECT id, username, email, password_hash, role, display_name, avatar_url, is_active, data_root, created_at, updated_at, last_login_at FROM users WHERE username = $1 ` func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error) { row := q.db.QueryRow(ctx, getUserByUsername, username) var i User err := row.Scan( &i.ID, &i.Username, &i.Email, &i.PasswordHash, &i.Role, &i.DisplayName, &i.AvatarUrl, &i.IsActive, &i.DataRoot, &i.CreatedAt, &i.UpdatedAt, &i.LastLoginAt, ) return i, err } const upsertUserByUsername = `-- name: UpsertUserByUsername :one INSERT INTO users (username, email, password_hash, role, display_name, avatar_url, is_active, data_root) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8 ) ON CONFLICT (username) DO UPDATE SET email = EXCLUDED.email, password_hash = EXCLUDED.password_hash, role = EXCLUDED.role, display_name = EXCLUDED.display_name, avatar_url = EXCLUDED.avatar_url, is_active = EXCLUDED.is_active, data_root = EXCLUDED.data_root, updated_at = now() RETURNING id, username, email, password_hash, role, display_name, avatar_url, is_active, data_root, created_at, updated_at, last_login_at ` type UpsertUserByUsernameParams struct { Username string `json:"username"` Email pgtype.Text `json:"email"` PasswordHash string `json:"password_hash"` Role interface{} `json:"role"` DisplayName pgtype.Text `json:"display_name"` AvatarUrl pgtype.Text `json:"avatar_url"` IsActive bool `json:"is_active"` DataRoot pgtype.Text `json:"data_root"` } func (q *Queries) UpsertUserByUsername(ctx context.Context, arg UpsertUserByUsernameParams) (User, error) { row := q.db.QueryRow(ctx, upsertUserByUsername, arg.Username, arg.Email, arg.PasswordHash, arg.Role, arg.DisplayName, arg.AvatarUrl, arg.IsActive, arg.DataRoot, ) var i User err := row.Scan( &i.ID, &i.Username, &i.Email, &i.PasswordHash, &i.Role, &i.DisplayName, &i.AvatarUrl, &i.IsActive, &i.DataRoot, &i.CreatedAt, &i.UpdatedAt, &i.LastLoginAt, ) return i, err }