hiling_go/db/sqlc/users.sql.go

87 lines
2.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: users.sql
package db
import (
"context"
"database/sql"
)
const createUser = `-- name: CreateUser :one
INSERT INTO users (
username,
password
) VALUES ($1, $2)
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
`
type CreateUserParams struct {
Username string `json:"username"`
Password string `json:"password"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
row := q.db.QueryRowContext(ctx, createUser, arg.Username, arg.Password)
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,
&i.IsActive,
&i.SocialMedia,
&i.CreatedAt,
&i.UpdatedAt,
&i.About,
&i.Website,
)
return i, err
}
const updateAvatar = `-- name: UpdateAvatar :one
UPDATE users
SET avatar_picture = $1
WHERE id = $2
RETURNING avatar_picture
`
type UpdateAvatarParams struct {
AvatarPicture sql.NullString `json:"avatar_picture"`
ID int32 `json:"id"`
}
func (q *Queries) UpdateAvatar(ctx context.Context, arg UpdateAvatarParams) (sql.NullString, error) {
row := q.db.QueryRowContext(ctx, updateAvatar, arg.AvatarPicture, arg.ID)
var avatar_picture sql.NullString
err := row.Scan(&avatar_picture)
return avatar_picture, err
}
const updatePassword = `-- name: UpdatePassword :exec
UPDATE users
SET password = $1
WHERE id = $2
`
type UpdatePasswordParams struct {
Password string `json:"password"`
ID int32 `json:"id"`
}
func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error {
_, err := q.db.ExecContext(ctx, updatePassword, arg.Password, arg.ID)
return err
}