Enshi/enshi_back/db/go_queries/profiles_queries.sql.go
2025-02-03 23:42:08 +03:00

108 lines
2.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: profiles_queries.sql
package db_repo
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const clearProfileByUserId = `-- name: ClearProfileByUserId :one
UPDATE public.profiles
SET bio='', avatar_url='', website_url=''
WHERE user_id=$1
RETURNING user_id, bio, avatar_url, website_url
`
func (q *Queries) ClearProfileByUserId(ctx context.Context, userID int64) (Profile, error) {
row := q.db.QueryRow(ctx, clearProfileByUserId, userID)
var i Profile
err := row.Scan(
&i.UserID,
&i.Bio,
&i.AvatarUrl,
&i.WebsiteUrl,
)
return i, err
}
const createProfileForUser = `-- name: CreateProfileForUser :one
INSERT INTO public.profiles
(user_id, bio, avatar_url, website_url)
VALUES($1, '', '', '')
RETURNING user_id, bio, avatar_url, website_url
`
func (q *Queries) CreateProfileForUser(ctx context.Context, userID int64) (Profile, error) {
row := q.db.QueryRow(ctx, createProfileForUser, userID)
var i Profile
err := row.Scan(
&i.UserID,
&i.Bio,
&i.AvatarUrl,
&i.WebsiteUrl,
)
return i, err
}
const deleteProfileByUserId = `-- name: DeleteProfileByUserId :exec
DELETE FROM public.profiles
WHERE user_id=$1
`
func (q *Queries) DeleteProfileByUserId(ctx context.Context, userID int64) error {
_, err := q.db.Exec(ctx, deleteProfileByUserId, userID)
return err
}
const getProfileByUserId = `-- name: GetProfileByUserId :one
SELECT user_id, bio, avatar_url, website_url FROM public.profiles WHERE user_id = $1
`
func (q *Queries) GetProfileByUserId(ctx context.Context, userID int64) (Profile, error) {
row := q.db.QueryRow(ctx, getProfileByUserId, userID)
var i Profile
err := row.Scan(
&i.UserID,
&i.Bio,
&i.AvatarUrl,
&i.WebsiteUrl,
)
return i, err
}
const updateProfileByUserId = `-- name: UpdateProfileByUserId :one
UPDATE public.profiles
SET bio=$2, avatar_url=$3, website_url=$4
WHERE user_id=$1
RETURNING user_id, bio, avatar_url, website_url
`
type UpdateProfileByUserIdParams struct {
UserID int64 `json:"user_id"`
Bio pgtype.Text `json:"bio"`
AvatarUrl pgtype.Text `json:"avatar_url"`
WebsiteUrl pgtype.Text `json:"website_url"`
}
func (q *Queries) UpdateProfileByUserId(ctx context.Context, arg UpdateProfileByUserIdParams) (Profile, error) {
row := q.db.QueryRow(ctx, updateProfileByUserId,
arg.UserID,
arg.Bio,
arg.AvatarUrl,
arg.WebsiteUrl,
)
var i Profile
err := row.Scan(
&i.UserID,
&i.Bio,
&i.AvatarUrl,
&i.WebsiteUrl,
)
return i, err
}