naise_pos/db/sqlc/users.sql.go

77 lines
1.5 KiB
Go
Raw Normal View History

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"
"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 getUserById = `-- name: GetUserById :one
SELECT id, index_id, email, password, fullname, created_at, updated_at
FROM users
WHERE id = $1
`
func (q *Queries) GetUserById(ctx context.Context, id uuid.UUID) (User, error) {
row := q.db.QueryRowContext(ctx, getUserById, id)
var i User
err := row.Scan(
&i.ID,
&i.IndexID,
&i.Email,
&i.Password,
&i.Fullname,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}