skeleton/internal/database/confirmation.sql.go

97 lines
2.3 KiB
Go
Raw Normal View History

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