// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: otp.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CreateOtp = `-- name: CreateOtp :exec INSERT INTO otps (sent_to, medium, otp_for, otp, used, created_at, expires_at) VALUES ($1, $2, $3, $4, FALSE, $5, $6) ` type CreateOtpParams struct { SentTo string `json:"sent_to"` Medium string `json:"medium"` OtpFor string `json:"otp_for"` Otp string `json:"otp"` CreatedAt pgtype.Timestamptz `json:"created_at"` ExpiresAt pgtype.Timestamptz `json:"expires_at"` } func (q *Queries) CreateOtp(ctx context.Context, arg CreateOtpParams) error { _, err := q.db.Exec(ctx, CreateOtp, arg.SentTo, arg.Medium, arg.OtpFor, arg.Otp, arg.CreatedAt, arg.ExpiresAt, ) return err } const GetOtp = `-- name: GetOtp :one SELECT id, sent_to, medium, otp_for, otp, used, used_at, created_at, expires_at FROM otps WHERE sent_to = $1 AND otp_for = $2 AND medium = $3 ORDER BY created_at DESC LIMIT 1 ` type GetOtpParams struct { SentTo string `json:"sent_to"` OtpFor string `json:"otp_for"` Medium string `json:"medium"` } func (q *Queries) GetOtp(ctx context.Context, arg GetOtpParams) (Otp, error) { row := q.db.QueryRow(ctx, GetOtp, arg.SentTo, arg.OtpFor, arg.Medium) var i Otp err := row.Scan( &i.ID, &i.SentTo, &i.Medium, &i.OtpFor, &i.Otp, &i.Used, &i.UsedAt, &i.CreatedAt, &i.ExpiresAt, ) return i, err } const MarkOtpAsUsed = `-- name: MarkOtpAsUsed :exec UPDATE otps SET used = TRUE, used_at = $2 WHERE id = $1 ` type MarkOtpAsUsedParams struct { ID int64 `json:"id"` UsedAt pgtype.Timestamptz `json:"used_at"` } func (q *Queries) MarkOtpAsUsed(ctx context.Context, arg MarkOtpAsUsedParams) error { _, err := q.db.Exec(ctx, MarkOtpAsUsed, arg.ID, arg.UsedAt) return err }