skeleton/internal/database/reset.sql.go
2020-07-19 15:52:08 +02:00

88 lines
1.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// source: reset.sql
package database
import (
"context"
"time"
)
const createReset = `-- name: CreateReset :one
INSERT INTO "reset" (
"user_id", "selector", "verifier", "expires_at"
) VALUES (
$1, $2, $3, $4
) RETURNING user_id, selector, verifier, expires_at
`
type CreateResetParams struct {
UserID int64 `json:"user_id"`
Selector string `json:"selector"`
Verifier []byte `json:"verifier"`
ExpiresAt time.Time `json:"expires_at"`
}
func (q *Queries) CreateReset(ctx context.Context, arg CreateResetParams) (Reset, error) {
row := q.db.QueryRowContext(ctx, createReset,
arg.UserID,
arg.Selector,
arg.Verifier,
arg.ExpiresAt,
)
var i Reset
err := row.Scan(
&i.UserID,
&i.Selector,
&i.Verifier,
&i.ExpiresAt,
)
return i, err
}
const destroyReset = `-- name: DestroyReset :exec
DELETE FROM "reset" WHERE "selector" = $1
`
func (q *Queries) DestroyReset(ctx context.Context, selector string) error {
_, err := q.db.ExecContext(ctx, destroyReset, selector)
return err
}
const getResetBySelector = `-- name: GetResetBySelector :one
SELECT
"user_id", "selector", "verifier", "expires_at"
FROM "reset"
WHERE "selector" = $1
`
func (q *Queries) GetResetBySelector(ctx context.Context, selector string) (Reset, error) {
row := q.db.QueryRowContext(ctx, getResetBySelector, selector)
var i Reset
err := row.Scan(
&i.UserID,
&i.Selector,
&i.Verifier,
&i.ExpiresAt,
)
return i, err
}
const getResetByUserID = `-- name: GetResetByUserID :one
SELECT
"user_id", "selector", "verifier", "expires_at"
FROM "reset"
WHERE "user_id" = $1
`
func (q *Queries) GetResetByUserID(ctx context.Context, userID int64) (Reset, error) {
row := q.db.QueryRowContext(ctx, getResetByUserID, userID)
var i Reset
err := row.Scan(
&i.UserID,
&i.Selector,
&i.Verifier,
&i.ExpiresAt,
)
return i, err
}