72 lines
1.4 KiB
Go
72 lines
1.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: users.sql
|
|
|
|
package database
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (id, created_at, updated_at, email, hashed_password)
|
|
VALUES (
|
|
gen_random_uuid(),
|
|
NOW(),
|
|
NOW(),
|
|
$1,
|
|
$2
|
|
)
|
|
RETURNING id, created_at, updated_at, email, hashed_password
|
|
`
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, email string, hashed_password string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, email, hashed_password)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Email,
|
|
&i.HashedPassword,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteUser = `-- name: DeleteUser :one
|
|
DELETE FROM users
|
|
RETURNING id, created_at, updated_at, email, hashed_password
|
|
`
|
|
|
|
func (q *Queries) DeleteUser(ctx context.Context) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, deleteUser)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Email,
|
|
&i.HashedPassword,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, created_at, updated_at, email, hashed_password FROM users
|
|
WHERE users.email = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Email,
|
|
&i.HashedPassword,
|
|
)
|
|
return i, err
|
|
}
|