// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.28.0 // source: query.sql package database import ( "context" "database/sql" ) const addPointsToUser = `-- name: AddPointsToUser :exec UPDATE users SET points = points + ? WHERE id = ? ` type AddPointsToUserParams struct { Points int64 ID int64 } func (q *Queries) AddPointsToUser(ctx context.Context, arg AddPointsToUserParams) error { _, err := q.db.ExecContext(ctx, addPointsToUser, arg.Points, arg.ID) return err } const createUser = `-- name: CreateUser :exec INSERT INTO users (id, referrer_id, points) VALUES (?, ?, 0) ON CONFLICT(id) DO NOTHING ` type CreateUserParams struct { ID int64 ReferrerID sql.NullInt64 } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error { _, err := q.db.ExecContext(ctx, createUser, arg.ID, arg.ReferrerID) return err } const getUser = `-- name: GetUser :one SELECT id, points, referrer_id FROM users WHERE id = ? ` type GetUserRow struct { ID int64 Points int64 ReferrerID sql.NullInt64 } func (q *Queries) GetUser(ctx context.Context, id int64) (GetUserRow, error) { row := q.db.QueryRowContext(ctx, getUser, id) var i GetUserRow err := row.Scan(&i.ID, &i.Points, &i.ReferrerID) return i, err } const reducePointsFromUser = `-- name: ReducePointsFromUser :one UPDATE users SET points = points - ? WHERE id = ? RETURNING points ` type ReducePointsFromUserParams struct { Points int64 ID int64 } func (q *Queries) ReducePointsFromUser(ctx context.Context, arg ReducePointsFromUserParams) (int64, error) { row := q.db.QueryRowContext(ctx, reducePointsFromUser, arg.Points, arg.ID) var points int64 err := row.Scan(&points) return points, err } const updateReferrer = `-- name: UpdateReferrer :exec UPDATE users SET referrer_id = ? WHERE id = ? AND referrer_id IS NULL ` type UpdateReferrerParams struct { ReferrerID sql.NullInt64 ID int64 } func (q *Queries) UpdateReferrer(ctx context.Context, arg UpdateReferrerParams) error { _, err := q.db.ExecContext(ctx, updateReferrer, arg.ReferrerID, arg.ID) return err } const upsertReferrer = `-- name: UpsertReferrer :exec INSERT INTO users (id, referrer_id, points) VALUES (?, ?, 0) ON CONFLICT(id) DO UPDATE SET referrer_id = excluded.referrer_id WHERE users.referrer_id IS NULL ` type UpsertReferrerParams struct { ID int64 ReferrerID sql.NullInt64 } func (q *Queries) UpsertReferrer(ctx context.Context, arg UpsertReferrerParams) error { _, err := q.db.ExecContext(ctx, upsertReferrer, arg.ID, arg.ReferrerID) return err }