2023-03-13 09:24:59 +07:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.17.2
|
|
|
|
// source: users.sql
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-03-19 18:17:17 +07:00
|
|
|
"database/sql"
|
2023-03-13 09:24:59 +07:00
|
|
|
|
|
|
|
"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
|
|
|
|
}
|
|
|
|
|
2023-03-14 17:39:40 +07:00
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
2023-03-19 18:17:17 +07:00
|
|
|
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
|
2023-03-14 17:39:40 +07:00
|
|
|
WHERE email = $1
|
|
|
|
`
|
|
|
|
|
2023-03-19 18:17:17 +07:00
|
|
|
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) {
|
2023-03-14 17:39:40 +07:00
|
|
|
row := q.db.QueryRowContext(ctx, getUserByEmail, email)
|
2023-03-19 18:17:17 +07:00
|
|
|
var i GetUserByEmailRow
|
2023-03-14 17:39:40 +07:00
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.IndexID,
|
|
|
|
&i.Email,
|
|
|
|
&i.Password,
|
|
|
|
&i.Fullname,
|
|
|
|
&i.CreatedAt,
|
|
|
|
&i.UpdatedAt,
|
2023-03-19 18:17:17 +07:00
|
|
|
&i.ID_2,
|
|
|
|
&i.IndexID_2,
|
|
|
|
&i.Name,
|
|
|
|
&i.OwnerID,
|
|
|
|
&i.CreatedAt_2,
|
|
|
|
&i.UpdatedAt_2,
|
2023-03-14 17:39:40 +07:00
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2023-03-13 09:24:59 +07:00
|
|
|
const getUserById = `-- name: GetUserById :one
|
2023-03-19 18:17:17 +07:00
|
|
|
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
|
2023-03-13 09:24:59 +07:00
|
|
|
`
|
|
|
|
|
2023-03-19 18:17:17 +07:00
|
|
|
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) {
|
2023-03-13 09:24:59 +07:00
|
|
|
row := q.db.QueryRowContext(ctx, getUserById, id)
|
2023-03-19 18:17:17 +07:00
|
|
|
var i GetUserByIdRow
|
2023-03-13 09:24:59 +07:00
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.IndexID,
|
|
|
|
&i.Email,
|
|
|
|
&i.Password,
|
|
|
|
&i.Fullname,
|
|
|
|
&i.CreatedAt,
|
|
|
|
&i.UpdatedAt,
|
2023-03-19 18:17:17 +07:00
|
|
|
&i.ID_2,
|
|
|
|
&i.IndexID_2,
|
|
|
|
&i.Name,
|
|
|
|
&i.OwnerID,
|
|
|
|
&i.CreatedAt_2,
|
|
|
|
&i.UpdatedAt_2,
|
2023-03-13 09:24:59 +07:00
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|