skeleton/internal/database/confirmation.sql.go
2020-07-21 22:50:11 +02:00

96 lines
2.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// source: confirmation.sql
package database
import (
"context"
"time"
)
const createEmailConfirmation = `-- name: CreateEmailConfirmation :one
INSERT INTO "email_confirmation" (
"selector",
"verifier",
"valid_until",
"email_address"
) VALUES (
$1,
$2,
$3,
$4
) RETURNING email_address, selector, verifier, valid_until
`
type CreateEmailConfirmationParams struct {
Selector string `json:"selector"`
Verifier []byte `json:"verifier"`
ValidUntil time.Time `json:"valid_until"`
EmailAddress string `json:"email_address"`
}
func (q *Queries) CreateEmailConfirmation(ctx context.Context, arg CreateEmailConfirmationParams) (EmailConfirmation, error) {
row := q.db.QueryRowContext(ctx, createEmailConfirmation,
arg.Selector,
arg.Verifier,
arg.ValidUntil,
arg.EmailAddress,
)
var i EmailConfirmation
err := row.Scan(
&i.EmailAddress,
&i.Selector,
&i.Verifier,
&i.ValidUntil,
)
return i, err
}
const destroyEmailConfirmation = `-- name: DestroyEmailConfirmation :exec
DELETE FROM "email_confirmation" WHERE "email_address" = $1
`
func (q *Queries) DestroyEmailConfirmation(ctx context.Context, emailAddress string) error {
_, err := q.db.ExecContext(ctx, destroyEmailConfirmation, emailAddress)
return err
}
const getEmailConfirmationByAddress = `-- name: GetEmailConfirmationByAddress :one
SELECT
email_address, selector, verifier, valid_until
FROM "email_confirmation"
WHERE "email_address" = $1
LIMIT 1
`
func (q *Queries) GetEmailConfirmationByAddress(ctx context.Context, emailAddress string) (EmailConfirmation, error) {
row := q.db.QueryRowContext(ctx, getEmailConfirmationByAddress, emailAddress)
var i EmailConfirmation
err := row.Scan(
&i.EmailAddress,
&i.Selector,
&i.Verifier,
&i.ValidUntil,
)
return i, err
}
const getEmailConfirmationBySelector = `-- name: GetEmailConfirmationBySelector :one
SELECT
email_address, selector, verifier, valid_until
FROM "email_confirmation"
WHERE "selector" = $1
LIMIT 1
`
func (q *Queries) GetEmailConfirmationBySelector(ctx context.Context, selector string) (EmailConfirmation, error) {
row := q.db.QueryRowContext(ctx, getEmailConfirmationBySelector, selector)
var i EmailConfirmation
err := row.Scan(
&i.EmailAddress,
&i.Selector,
&i.Verifier,
&i.ValidUntil,
)
return i, err
}