Files
music-index/api/sqlc/users.sql.go
T

59 lines
1.4 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: users.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const checkUserExistsByEmail = `-- name: CheckUserExistsByEmail :one
SELECT id FROM users WHERE user_mail = $1
`
func (q *Queries) CheckUserExistsByEmail(ctx context.Context, userMail string) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, checkUserExistsByEmail, userMail)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const createUser = `-- name: CreateUser :one
INSERT INTO users (id, user_name, user_mail, password) VALUES ($1, $2, $3, $4) RETURNING id
`
type CreateUserParams struct {
ID pgtype.UUID `json:"id"`
UserName string `json:"user_name"`
UserMail string `json:"user_mail"`
Password string `json:"password"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, createUser,
arg.ID,
arg.UserName,
arg.UserMail,
arg.Password,
)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const getUsernameByID = `-- name: GetUsernameByID :one
SELECT user_name FROM users WHERE id = $1
`
// users.sql
func (q *Queries) GetUsernameByID(ctx context.Context, id pgtype.UUID) (string, error) {
row := q.db.QueryRow(ctx, getUsernameByID, id)
var user_name string
err := row.Scan(&user_name)
return user_name, err
}