145 lines
3.6 KiB
Go
145 lines
3.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.17.2
|
|
// source: users.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (
|
|
email,
|
|
password,
|
|
fullname
|
|
) VALUES ($1, $2, $3)
|
|
RETURNING id, index_id, email, password, fullname, created_at, updated_at
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
Fullname string `json:"fullname"`
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, arg.Email, arg.Password, arg.Fullname)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.IndexID,
|
|
&i.Email,
|
|
&i.Password,
|
|
&i.Fullname,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPasswordByEmail = `-- name: GetPasswordByEmail :one
|
|
SELECT password
|
|
FROM users
|
|
WHERE email = $1
|
|
`
|
|
|
|
func (q *Queries) GetPasswordByEmail(ctx context.Context, email string) (string, error) {
|
|
row := q.db.QueryRowContext(ctx, getPasswordByEmail, email)
|
|
var password string
|
|
err := row.Scan(&password)
|
|
return password, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT u.id, u.index_id, email, password, fullname, u.created_at, u.updated_at, m.id, m.index_id, name, owner_id, m.created_at, m.updated_at
|
|
FROM users u
|
|
JOIN merchants m on u.id = m.owner_id
|
|
WHERE email = $1
|
|
`
|
|
|
|
type GetUserByEmailRow struct {
|
|
ID uuid.UUID `json:"id"`
|
|
IndexID int64 `json:"index_id"`
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
Fullname string `json:"fullname"`
|
|
CreatedAt sql.NullTime `json:"created_at"`
|
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
|
ID_2 uuid.UUID `json:"id_2"`
|
|
IndexID_2 int64 `json:"index_id_2"`
|
|
Name string `json:"name"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
CreatedAt_2 sql.NullTime `json:"created_at_2"`
|
|
UpdatedAt_2 sql.NullTime `json:"updated_at_2"`
|
|
}
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByEmail, email)
|
|
var i GetUserByEmailRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.IndexID,
|
|
&i.Email,
|
|
&i.Password,
|
|
&i.Fullname,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ID_2,
|
|
&i.IndexID_2,
|
|
&i.Name,
|
|
&i.OwnerID,
|
|
&i.CreatedAt_2,
|
|
&i.UpdatedAt_2,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserById = `-- name: GetUserById :one
|
|
SELECT u.id, u.index_id, email, password, fullname, u.created_at, u.updated_at, m.id, m.index_id, name, owner_id, m.created_at, m.updated_at
|
|
FROM users u
|
|
JOIN merchants m on u.id = m.owner_id
|
|
WHERE u.id = $1
|
|
`
|
|
|
|
type GetUserByIdRow struct {
|
|
ID uuid.UUID `json:"id"`
|
|
IndexID int64 `json:"index_id"`
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
Fullname string `json:"fullname"`
|
|
CreatedAt sql.NullTime `json:"created_at"`
|
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
|
ID_2 uuid.UUID `json:"id_2"`
|
|
IndexID_2 int64 `json:"index_id_2"`
|
|
Name string `json:"name"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
CreatedAt_2 sql.NullTime `json:"created_at_2"`
|
|
UpdatedAt_2 sql.NullTime `json:"updated_at_2"`
|
|
}
|
|
|
|
func (q *Queries) GetUserById(ctx context.Context, id uuid.UUID) (GetUserByIdRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserById, id)
|
|
var i GetUserByIdRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.IndexID,
|
|
&i.Email,
|
|
&i.Password,
|
|
&i.Fullname,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ID_2,
|
|
&i.IndexID_2,
|
|
&i.Name,
|
|
&i.OwnerID,
|
|
&i.CreatedAt_2,
|
|
&i.UpdatedAt_2,
|
|
)
|
|
return i, err
|
|
}
|