// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.26.0
// source: remember_2fa.sql

package db

import (
	"context"
	"database/sql"
)

const checkRemember2FAToken = `-- name: CheckRemember2FAToken :one
SELECT EXISTS (SELECT created_at, user_id, code_hash, expires FROM remember_2fa WHERE user_id = ? AND code_hash = ? AND expires > ?3)
`

type CheckRemember2FATokenParams struct {
	UserID   string
	CodeHash []byte
	Now      int64
}

func (q *Queries) CheckRemember2FAToken(ctx context.Context, arg CheckRemember2FATokenParams) (int64, error) {
	row := q.db.QueryRowContext(ctx, checkRemember2FAToken, arg.UserID, arg.CodeHash, arg.Now)
	var created_at int64
	err := row.Scan(&created_at)
	return created_at, err
}

const createRemember2FAToken = `-- name: CreateRemember2FAToken :exec
INSERT INTO remember_2fa (created_at,user_id,code_hash,expires) VALUES (?,?,?,?)
`

type CreateRemember2FATokenParams struct {
	CreatedAt int64
	UserID    string
	CodeHash  []byte
	Expires   int64
}

func (q *Queries) CreateRemember2FAToken(ctx context.Context, arg CreateRemember2FATokenParams) error {
	_, err := q.db.ExecContext(ctx, createRemember2FAToken,
		arg.CreatedAt,
		arg.UserID,
		arg.CodeHash,
		arg.Expires,
	)
	return err
}

const deleteRemember2FAToken = `-- name: DeleteRemember2FAToken :execresult
DELETE FROM remember_2fa WHERE (user_id = ? AND code_hash = ?)
`

type DeleteRemember2FATokenParams struct {
	UserID   string
	CodeHash []byte
}

func (q *Queries) DeleteRemember2FAToken(ctx context.Context, arg DeleteRemember2FATokenParams) (sql.Result, error) {
	return q.db.ExecContext(ctx, deleteRemember2FAToken, arg.UserID, arg.CodeHash)
}

const deleteRemember2FATokens = `-- name: DeleteRemember2FATokens :execresult
DELETE FROM remember_2fa WHERE user_id = ? OR expires < ?2
`

type DeleteRemember2FATokensParams struct {
	UserID string
	Now    int64
}

func (q *Queries) DeleteRemember2FATokens(ctx context.Context, arg DeleteRemember2FATokensParams) (sql.Result, error) {
	return q.db.ExecContext(ctx, deleteRemember2FATokens, arg.UserID, arg.Now)
}
