94 lines
2.3 KiB
Go
94 lines
2.3 KiB
Go
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
// source: confirmation.sql
|
||
|
|
||
|
package database
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const createConfirmation = `-- name: CreateConfirmation :one
|
||
|
INSERT INTO "public"."confirmation" (
|
||
|
"email_address", "user_id", "selector", "verifier", "expires_at"
|
||
|
) VALUES (
|
||
|
$1, $2, $3, $4, $5
|
||
|
) RETURNING email_address, user_id, selector, verifier, expires_at
|
||
|
`
|
||
|
|
||
|
type CreateConfirmationParams struct {
|
||
|
EmailAddress string `json:"email_address"`
|
||
|
UserID int64 `json:"user_id"`
|
||
|
Selector string `json:"selector"`
|
||
|
Verifier []byte `json:"verifier"`
|
||
|
ExpiresAt time.Time `json:"expires_at"`
|
||
|
}
|
||
|
|
||
|
func (q *Queries) CreateConfirmation(ctx context.Context, arg CreateConfirmationParams) (Confirmation, error) {
|
||
|
row := q.db.QueryRowContext(ctx, createConfirmation,
|
||
|
arg.EmailAddress,
|
||
|
arg.UserID,
|
||
|
arg.Selector,
|
||
|
arg.Verifier,
|
||
|
arg.ExpiresAt,
|
||
|
)
|
||
|
var i Confirmation
|
||
|
err := row.Scan(
|
||
|
&i.EmailAddress,
|
||
|
&i.UserID,
|
||
|
&i.Selector,
|
||
|
&i.Verifier,
|
||
|
&i.ExpiresAt,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const destroyConfirmation = `-- name: DestroyConfirmation :exec
|
||
|
DELETE FROM "public"."confirmation" WHERE "selector" = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) DestroyConfirmation(ctx context.Context, selector string) error {
|
||
|
_, err := q.db.ExecContext(ctx, destroyConfirmation, selector)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
const getConfirmationBySelector = `-- name: GetConfirmationBySelector :one
|
||
|
SELECT
|
||
|
"email_address", "user_id", "selector", "verifier", "expires_at"
|
||
|
FROM "public"."confirmation"
|
||
|
WHERE "selector" = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetConfirmationBySelector(ctx context.Context, selector string) (Confirmation, error) {
|
||
|
row := q.db.QueryRowContext(ctx, getConfirmationBySelector, selector)
|
||
|
var i Confirmation
|
||
|
err := row.Scan(
|
||
|
&i.EmailAddress,
|
||
|
&i.UserID,
|
||
|
&i.Selector,
|
||
|
&i.Verifier,
|
||
|
&i.ExpiresAt,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const getConfirmationByUserID = `-- name: GetConfirmationByUserID :one
|
||
|
SELECT
|
||
|
"email_address", "user_id", "selector", "verifier", "expires_at"
|
||
|
FROM "public"."confirmation"
|
||
|
WHERE "user_id" = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetConfirmationByUserID(ctx context.Context, userID int64) (Confirmation, error) {
|
||
|
row := q.db.QueryRowContext(ctx, getConfirmationByUserID, userID)
|
||
|
var i Confirmation
|
||
|
err := row.Scan(
|
||
|
&i.EmailAddress,
|
||
|
&i.UserID,
|
||
|
&i.Selector,
|
||
|
&i.Verifier,
|
||
|
&i.ExpiresAt,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|