hiling_go/db/sqlc/users.sql.go

88 lines
2.0 KiB
Go
Raw Normal View History

2023-09-08 22:24:58 +07:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
2024-08-19 07:40:01 +07:00
// sqlc v1.26.0
2023-09-08 22:24:58 +07:00
// source: users.sql
package db
import (
"context"
2024-02-06 11:55:25 +07:00
"github.com/jackc/pgx/v5/pgtype"
2023-09-08 22:24:58 +07:00
)
2023-09-12 17:07:03 +07:00
const createUser = `-- name: CreateUser :one
2023-09-08 22:24:58 +07:00
INSERT INTO users (
2023-09-12 17:07:03 +07:00
username,
password
) VALUES ($1, $2)
2023-10-09 16:25:39 +07:00
RETURNING id, email, username, password, avatar_picture, google_sign_in_payload, banned_at, banned_until, ban_reason, is_permaban, is_admin, is_critics, is_verified, is_active, social_media, created_at, updated_at, about, website
2023-09-12 17:07:03 +07:00
`
type CreateUserParams struct {
Username string `json:"username"`
Password string `json:"password"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
2024-02-06 11:55:25 +07:00
row := q.db.QueryRow(ctx, createUser, arg.Username, arg.Password)
2023-09-12 17:07:03 +07:00
var i User
err := row.Scan(
&i.ID,
&i.Email,
&i.Username,
&i.Password,
&i.AvatarPicture,
&i.GoogleSignInPayload,
&i.BannedAt,
&i.BannedUntil,
&i.BanReason,
&i.IsPermaban,
&i.IsAdmin,
&i.IsCritics,
&i.IsVerified,
2023-09-13 21:42:04 +07:00
&i.IsActive,
2023-09-12 17:07:03 +07:00
&i.SocialMedia,
&i.CreatedAt,
&i.UpdatedAt,
2023-10-09 16:25:39 +07:00
&i.About,
&i.Website,
2023-09-12 17:07:03 +07:00
)
return i, err
}
2023-10-09 16:25:39 +07:00
const updateAvatar = `-- name: UpdateAvatar :one
UPDATE users
SET avatar_picture = $1
WHERE id = $2
RETURNING avatar_picture
`
type UpdateAvatarParams struct {
2024-02-06 11:55:25 +07:00
AvatarPicture pgtype.Text `json:"avatar_picture"`
ID int32 `json:"id"`
2023-10-09 16:25:39 +07:00
}
2024-02-06 11:55:25 +07:00
func (q *Queries) UpdateAvatar(ctx context.Context, arg UpdateAvatarParams) (pgtype.Text, error) {
row := q.db.QueryRow(ctx, updateAvatar, arg.AvatarPicture, arg.ID)
var avatar_picture pgtype.Text
2023-10-09 16:25:39 +07:00
err := row.Scan(&avatar_picture)
return avatar_picture, err
}
2023-09-12 17:07:03 +07:00
const updatePassword = `-- name: UpdatePassword :exec
UPDATE users
SET password = $1
WHERE id = $2
2023-09-08 22:24:58 +07:00
`
2023-09-12 17:07:03 +07:00
type UpdatePasswordParams struct {
Password string `json:"password"`
ID int32 `json:"id"`
}
func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error {
2024-02-06 11:55:25 +07:00
_, err := q.db.Exec(ctx, updatePassword, arg.Password, arg.ID)
2023-09-08 22:24:58 +07:00
return err
}