saasitone/pkg/models/sqlc/users.sql.go

106 lines
2.2 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: users.sql
package sqlc
import (
"context"
)
const createUser = `-- name: CreateUser :one
INSERT INTO users (
name, email, password
) VALUES (
?, ?, ?
) RETURNING id, name, email, password, verified, created_at
`
type CreateUserParams struct {
Name string `db:"name"`
Email string `db:"email"`
Password string `db:"password"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
row := q.db.QueryRowContext(ctx, createUser, arg.Name, arg.Email, arg.Password)
var i User
err := row.Scan(
&i.ID,
&i.Name,
&i.Email,
&i.Password,
&i.Verified,
&i.CreatedAt,
)
return i, err
}
const getUserByEmail = `-- name: GetUserByEmail :one
SELECT id, name, email, password, verified, created_at FROM users
WHERE email = lower(?)
LIMIT 1
`
func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error) {
row := q.db.QueryRowContext(ctx, getUserByEmail, lower)
var i User
err := row.Scan(
&i.ID,
&i.Name,
&i.Email,
&i.Password,
&i.Verified,
&i.CreatedAt,
)
return i, err
}
const getUserByID = `-- name: GetUserByID :one
SELECT id, name, email, password, verified, created_at FROM users
WHERE id = ?
LIMIT 1
`
func (q *Queries) GetUserByID(ctx context.Context, id int) (User, error) {
row := q.db.QueryRowContext(ctx, getUserByID, id)
var i User
err := row.Scan(
&i.ID,
&i.Name,
&i.Email,
&i.Password,
&i.Verified,
&i.CreatedAt,
)
return i, err
}
const updateUserPassword = `-- name: UpdateUserPassword :exec
UPDATE users
SET password = ?
WHERE id = ?
`
type UpdateUserPasswordParams struct {
Password string `db:"password"`
ID int `db:"id"`
}
func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error {
_, err := q.db.ExecContext(ctx, updateUserPassword, arg.Password, arg.ID)
return err
}
const updateUserSetVerified = `-- name: UpdateUserSetVerified :exec
UPDATE users
SET verified = 1
WHERE email = ?
`
func (q *Queries) UpdateUserSetVerified(ctx context.Context, email string) error {
_, err := q.db.ExecContext(ctx, updateUserSetVerified, email)
return err
}