// 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 createUser = `-- name: CreateUser :one INSERT INTO users ( email, password_hash, role, full_name ) VALUES ( $1, $2, $3, $4 ) RETURNING id, email, password_hash, role, full_name, is_active, created_at, updated_at ` type CreateUserParams struct { Email string `json:"email"` PasswordHash pgtype.Text `json:"password_hash"` Role UserRole `json:"role"` FullName string `json:"full_name"` } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { row := q.db.QueryRow(ctx, createUser, arg.Email, arg.PasswordHash, arg.Role, arg.FullName, ) var i User err := row.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getAuthUserByEmail = `-- name: GetAuthUserByEmail :one SELECT u.id AS user_id, u.email AS user_email, u.role AS user_role, u.full_name AS user_full_name, u.is_active AS user_is_active, u.password_hash AS user_password_hash, u.created_at AS user_created_at, u.updated_at AS user_updated_at, p.user_id AS profile_user_id, p.preferred_name, p.profile_icon_url, p.headline, p.bio, p.timezone, p.locale, p.grade_level, p.learning_goal, p.created_at AS profile_created_at, p.updated_at AS profile_updated_at FROM users u LEFT JOIN profiles p ON p.user_id = u.id WHERE u.email = $1 ` type GetAuthUserByEmailRow struct { UserID int64 `json:"user_id"` UserEmail string `json:"user_email"` UserRole UserRole `json:"user_role"` UserFullName string `json:"user_full_name"` UserIsActive bool `json:"user_is_active"` UserPasswordHash pgtype.Text `json:"user_password_hash"` UserCreatedAt pgtype.Timestamptz `json:"user_created_at"` UserUpdatedAt pgtype.Timestamptz `json:"user_updated_at"` ProfileUserID pgtype.Int8 `json:"profile_user_id"` PreferredName pgtype.Text `json:"preferred_name"` ProfileIconUrl pgtype.Text `json:"profile_icon_url"` Headline pgtype.Text `json:"headline"` Bio pgtype.Text `json:"bio"` Timezone pgtype.Text `json:"timezone"` Locale pgtype.Text `json:"locale"` GradeLevel pgtype.Text `json:"grade_level"` LearningGoal pgtype.Text `json:"learning_goal"` ProfileCreatedAt pgtype.Timestamptz `json:"profile_created_at"` ProfileUpdatedAt pgtype.Timestamptz `json:"profile_updated_at"` } func (q *Queries) GetAuthUserByEmail(ctx context.Context, email string) (GetAuthUserByEmailRow, error) { row := q.db.QueryRow(ctx, getAuthUserByEmail, email) var i GetAuthUserByEmailRow err := row.Scan( &i.UserID, &i.UserEmail, &i.UserRole, &i.UserFullName, &i.UserIsActive, &i.UserPasswordHash, &i.UserCreatedAt, &i.UserUpdatedAt, &i.ProfileUserID, &i.PreferredName, &i.ProfileIconUrl, &i.Headline, &i.Bio, &i.Timezone, &i.Locale, &i.GradeLevel, &i.LearningGoal, &i.ProfileCreatedAt, &i.ProfileUpdatedAt, ) return i, err } const getAuthUserByID = `-- name: GetAuthUserByID :one SELECT u.id AS user_id, u.email AS user_email, u.role AS user_role, u.full_name AS user_full_name, u.is_active AS user_is_active, u.created_at AS user_created_at, u.updated_at AS user_updated_at, p.user_id AS profile_user_id, p.preferred_name, p.profile_icon_url, p.headline, p.bio, p.timezone, p.locale, p.grade_level, p.learning_goal, p.created_at AS profile_created_at, p.updated_at AS profile_updated_at FROM users u LEFT JOIN profiles p ON p.user_id = u.id WHERE u.id = $1 ` type GetAuthUserByIDRow struct { UserID int64 `json:"user_id"` UserEmail string `json:"user_email"` UserRole UserRole `json:"user_role"` UserFullName string `json:"user_full_name"` UserIsActive bool `json:"user_is_active"` UserCreatedAt pgtype.Timestamptz `json:"user_created_at"` UserUpdatedAt pgtype.Timestamptz `json:"user_updated_at"` ProfileUserID pgtype.Int8 `json:"profile_user_id"` PreferredName pgtype.Text `json:"preferred_name"` ProfileIconUrl pgtype.Text `json:"profile_icon_url"` Headline pgtype.Text `json:"headline"` Bio pgtype.Text `json:"bio"` Timezone pgtype.Text `json:"timezone"` Locale pgtype.Text `json:"locale"` GradeLevel pgtype.Text `json:"grade_level"` LearningGoal pgtype.Text `json:"learning_goal"` ProfileCreatedAt pgtype.Timestamptz `json:"profile_created_at"` ProfileUpdatedAt pgtype.Timestamptz `json:"profile_updated_at"` } func (q *Queries) GetAuthUserByID(ctx context.Context, id int64) (GetAuthUserByIDRow, error) { row := q.db.QueryRow(ctx, getAuthUserByID, id) var i GetAuthUserByIDRow err := row.Scan( &i.UserID, &i.UserEmail, &i.UserRole, &i.UserFullName, &i.UserIsActive, &i.UserCreatedAt, &i.UserUpdatedAt, &i.ProfileUserID, &i.PreferredName, &i.ProfileIconUrl, &i.Headline, &i.Bio, &i.Timezone, &i.Locale, &i.GradeLevel, &i.LearningGoal, &i.ProfileCreatedAt, &i.ProfileUpdatedAt, ) return i, err } const getUserByEmail = `-- name: GetUserByEmail :one SELECT id, email, password_hash, role, full_name, is_active, created_at, updated_at FROM users WHERE email = $1 ` func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) { row := q.db.QueryRow(ctx, getUserByEmail, email) var i User err := row.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getUserByID = `-- name: GetUserByID :one SELECT id, email, password_hash, role, full_name, is_active, created_at, updated_at FROM users WHERE id = $1 ` func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error) { row := q.db.QueryRow(ctx, getUserByID, id) var i User err := row.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getUserWithProfileByID = `-- name: GetUserWithProfileByID :one SELECT u.id AS user_id, u.email AS user_email, u.role AS user_role, u.full_name AS user_full_name, u.is_active AS user_is_active, u.created_at AS user_created_at, u.updated_at AS user_updated_at, p.user_id AS profile_user_id, p.preferred_name, p.profile_icon_url, p.headline, p.bio, p.timezone, p.locale, p.grade_level, p.learning_goal, p.created_at AS profile_created_at, p.updated_at AS profile_updated_at FROM users u LEFT JOIN profiles p ON p.user_id = u.id WHERE u.id = $1 ` type GetUserWithProfileByIDRow struct { UserID int64 `json:"user_id"` UserEmail string `json:"user_email"` UserRole UserRole `json:"user_role"` UserFullName string `json:"user_full_name"` UserIsActive bool `json:"user_is_active"` UserCreatedAt pgtype.Timestamptz `json:"user_created_at"` UserUpdatedAt pgtype.Timestamptz `json:"user_updated_at"` ProfileUserID pgtype.Int8 `json:"profile_user_id"` PreferredName pgtype.Text `json:"preferred_name"` ProfileIconUrl pgtype.Text `json:"profile_icon_url"` Headline pgtype.Text `json:"headline"` Bio pgtype.Text `json:"bio"` Timezone pgtype.Text `json:"timezone"` Locale pgtype.Text `json:"locale"` GradeLevel pgtype.Text `json:"grade_level"` LearningGoal pgtype.Text `json:"learning_goal"` ProfileCreatedAt pgtype.Timestamptz `json:"profile_created_at"` ProfileUpdatedAt pgtype.Timestamptz `json:"profile_updated_at"` } func (q *Queries) GetUserWithProfileByID(ctx context.Context, id int64) (GetUserWithProfileByIDRow, error) { row := q.db.QueryRow(ctx, getUserWithProfileByID, id) var i GetUserWithProfileByIDRow err := row.Scan( &i.UserID, &i.UserEmail, &i.UserRole, &i.UserFullName, &i.UserIsActive, &i.UserCreatedAt, &i.UserUpdatedAt, &i.ProfileUserID, &i.PreferredName, &i.ProfileIconUrl, &i.Headline, &i.Bio, &i.Timezone, &i.Locale, &i.GradeLevel, &i.LearningGoal, &i.ProfileCreatedAt, &i.ProfileUpdatedAt, ) return i, err } const listUsersByRole = `-- name: ListUsersByRole :many SELECT id, email, password_hash, role, full_name, is_active, created_at, updated_at FROM users WHERE role = $1 ORDER BY full_name ASC ` func (q *Queries) ListUsersByRole(ctx context.Context, role UserRole) ([]User, error) { rows, err := q.db.Query(ctx, listUsersByRole, role) if err != nil { return nil, err } defer rows.Close() items := []User{} for rows.Next() { var i User if err := rows.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listUsersWithProfileByRole = `-- name: ListUsersWithProfileByRole :many SELECT u.id AS user_id, u.email AS user_email, u.role AS user_role, u.full_name AS user_full_name, u.is_active AS user_is_active, u.created_at AS user_created_at, u.updated_at AS user_updated_at, p.user_id AS profile_user_id, p.preferred_name, p.profile_icon_url, p.headline, p.bio, p.timezone, p.locale, p.grade_level, p.learning_goal, p.created_at AS profile_created_at, p.updated_at AS profile_updated_at FROM users u LEFT JOIN profiles p ON p.user_id = u.id WHERE u.role = $1 ORDER BY u.full_name ASC ` type ListUsersWithProfileByRoleRow struct { UserID int64 `json:"user_id"` UserEmail string `json:"user_email"` UserRole UserRole `json:"user_role"` UserFullName string `json:"user_full_name"` UserIsActive bool `json:"user_is_active"` UserCreatedAt pgtype.Timestamptz `json:"user_created_at"` UserUpdatedAt pgtype.Timestamptz `json:"user_updated_at"` ProfileUserID pgtype.Int8 `json:"profile_user_id"` PreferredName pgtype.Text `json:"preferred_name"` ProfileIconUrl pgtype.Text `json:"profile_icon_url"` Headline pgtype.Text `json:"headline"` Bio pgtype.Text `json:"bio"` Timezone pgtype.Text `json:"timezone"` Locale pgtype.Text `json:"locale"` GradeLevel pgtype.Text `json:"grade_level"` LearningGoal pgtype.Text `json:"learning_goal"` ProfileCreatedAt pgtype.Timestamptz `json:"profile_created_at"` ProfileUpdatedAt pgtype.Timestamptz `json:"profile_updated_at"` } func (q *Queries) ListUsersWithProfileByRole(ctx context.Context, role UserRole) ([]ListUsersWithProfileByRoleRow, error) { rows, err := q.db.Query(ctx, listUsersWithProfileByRole, role) if err != nil { return nil, err } defer rows.Close() items := []ListUsersWithProfileByRoleRow{} for rows.Next() { var i ListUsersWithProfileByRoleRow if err := rows.Scan( &i.UserID, &i.UserEmail, &i.UserRole, &i.UserFullName, &i.UserIsActive, &i.UserCreatedAt, &i.UserUpdatedAt, &i.ProfileUserID, &i.PreferredName, &i.ProfileIconUrl, &i.Headline, &i.Bio, &i.Timezone, &i.Locale, &i.GradeLevel, &i.LearningGoal, &i.ProfileCreatedAt, &i.ProfileUpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateUserActiveStatus = `-- name: UpdateUserActiveStatus :one UPDATE users SET is_active = $2, updated_at = NOW() WHERE id = $1 RETURNING id, email, password_hash, role, full_name, is_active, created_at, updated_at ` type UpdateUserActiveStatusParams struct { ID int64 `json:"id"` IsActive bool `json:"is_active"` } func (q *Queries) UpdateUserActiveStatus(ctx context.Context, arg UpdateUserActiveStatusParams) (User, error) { row := q.db.QueryRow(ctx, updateUserActiveStatus, arg.ID, arg.IsActive) var i User err := row.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const updateUserFullName = `-- name: UpdateUserFullName :one UPDATE users SET full_name = $2, updated_at = NOW() WHERE id = $1 RETURNING id, email, password_hash, role, full_name, is_active, created_at, updated_at ` type UpdateUserFullNameParams struct { ID int64 `json:"id"` FullName string `json:"full_name"` } func (q *Queries) UpdateUserFullName(ctx context.Context, arg UpdateUserFullNameParams) (User, error) { row := q.db.QueryRow(ctx, updateUserFullName, arg.ID, arg.FullName) var i User err := row.Scan( &i.ID, &i.Email, &i.PasswordHash, &i.Role, &i.FullName, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const upsertUserProfile = `-- name: UpsertUserProfile :one INSERT INTO profiles ( user_id, preferred_name, profile_icon_url, headline, bio, timezone, locale, grade_level, learning_goal ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9 ) ON CONFLICT (user_id) DO UPDATE SET preferred_name = EXCLUDED.preferred_name, profile_icon_url = EXCLUDED.profile_icon_url, headline = EXCLUDED.headline, bio = EXCLUDED.bio, timezone = EXCLUDED.timezone, locale = EXCLUDED.locale, grade_level = EXCLUDED.grade_level, learning_goal = EXCLUDED.learning_goal, updated_at = NOW() RETURNING user_id, preferred_name, profile_icon_url, headline, bio, timezone, locale, grade_level, learning_goal, created_at, updated_at ` type UpsertUserProfileParams struct { UserID int64 `json:"user_id"` PreferredName pgtype.Text `json:"preferred_name"` ProfileIconUrl pgtype.Text `json:"profile_icon_url"` Headline pgtype.Text `json:"headline"` Bio pgtype.Text `json:"bio"` Timezone pgtype.Text `json:"timezone"` Locale pgtype.Text `json:"locale"` GradeLevel pgtype.Text `json:"grade_level"` LearningGoal pgtype.Text `json:"learning_goal"` } func (q *Queries) UpsertUserProfile(ctx context.Context, arg UpsertUserProfileParams) (Profile, error) { row := q.db.QueryRow(ctx, upsertUserProfile, arg.UserID, arg.PreferredName, arg.ProfileIconUrl, arg.Headline, arg.Bio, arg.Timezone, arg.Locale, arg.GradeLevel, arg.LearningGoal, ) var i Profile err := row.Scan( &i.UserID, &i.PreferredName, &i.ProfileIconUrl, &i.Headline, &i.Bio, &i.Timezone, &i.Locale, &i.GradeLevel, &i.LearningGoal, &i.CreatedAt, &i.UpdatedAt, ) return i, err }