hiling_go/db/sqlc/users.sql.go

114 lines
2.5 KiB
Go
Raw Normal View History

2023-09-08 22:24:58 +07:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
// source: users.sql
package db
import (
"context"
2023-09-12 17:07:03 +07:00
"database/sql"
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-09-13 21:42:04 +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
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) {
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,
2023-09-13 21:42:04 +07:00
&i.IsActive,
2023-09-12 17:07:03 +07:00
&i.SocialMedia,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
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 {
_, err := q.db.ExecContext(ctx, updatePassword, arg.Password, arg.ID)
2023-09-08 22:24:58 +07:00
return err
}
2023-09-12 17:07:03 +07:00
const updateUser = `-- name: UpdateUser :one
UPDATE users
SET
email = COALESCE($1, email),
username = COALESCE($2, username),
avatar_picture = COALESCE($3, avatar_picture)
WHERE
id = $4
2023-09-13 21:42:04 +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
2023-09-12 17:07:03 +07:00
`
type UpdateUserParams struct {
Email sql.NullString `json:"email"`
Username sql.NullString `json:"username"`
AvatarPicture sql.NullString `json:"avatar_picture"`
ID int32 `json:"id"`
}
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) {
row := q.db.QueryRowContext(ctx, updateUser,
arg.Email,
arg.Username,
arg.AvatarPicture,
arg.ID,
)
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,
)
return i, err
}