db

package
v0.0.0-...-19fc164 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB_CONNECTION_RETRIES int = 3
View Source
var DB_CONNECTION_RETRY_DELAY time.Duration = 1

Functions

func StringtoPGText

func StringtoPGText(s string) pgtype.Text

func TimeToPGDate

func TimeToPGDate(t time.Time) pgtype.Date

func TimeToPGTimestamp

func TimeToPGTimestamp(t time.Time) pgtype.Timestamp

func TimeToPGTimestamptz

func TimeToPGTimestamptz(t time.Time) pgtype.Timestamptz

func UUIDToPGUUID

func UUIDToPGUUID(u uuid.UUID) pgtype.UUID

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type FilterMailsOnCreatedAtParams

type FilterMailsOnCreatedAtParams struct {
	Limit       int32
	CreatedAtLt pgtype.Timestamp
	CreatedAtGt pgtype.Timestamp
}

type InsertMailParams

type InsertMailParams struct {
	CreatedAt    pgtype.Timestamp
	MailProvider string
	MailFrom     string
	Success      bool
	Recipients   []string
	Subject      string
	Content      string
	Error        pgtype.Text
}

type Mail

type Mail struct {
	ID           int32
	CreatedAt    pgtype.Timestamp
	MailProvider string
	Success      bool
	// Encrypted sender email address
	MailFrom string
	// Encrypted array of recipient email addresses
	Recipients []string
	// Encrypted email subject
	Subject string
	// Encrypted email content
	Content string
	Error   pgtype.Text
}

type Querier

type Querier interface {
	CountAllMails(ctx context.Context) (int64, error)
	FilterMailsOnCreatedAt(ctx context.Context, arg FilterMailsOnCreatedAtParams) ([]Mail, error)
	InsertMail(ctx context.Context, arg InsertMailParams) (int32, error)
	SelectAllMails(ctx context.Context, arg SelectAllMailsParams) ([]Mail, error)
	SelectMailByID(ctx context.Context, id int32) (Mail, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func NewDB

func NewDB(dsn string, withTransaction bool) (*Queries, *pgx.Tx)

func (*Queries) CountAllMails

func (q *Queries) CountAllMails(ctx context.Context) (int64, error)

func (*Queries) FilterMailsOnCreatedAt

func (q *Queries) FilterMailsOnCreatedAt(ctx context.Context, arg FilterMailsOnCreatedAtParams) ([]Mail, error)

func (*Queries) InsertMail

func (q *Queries) InsertMail(ctx context.Context, arg InsertMailParams) (int32, error)

func (*Queries) SelectAllMails

func (q *Queries) SelectAllMails(ctx context.Context, arg SelectAllMailsParams) ([]Mail, error)

func (*Queries) SelectMailByID

func (q *Queries) SelectMailByID(ctx context.Context, id int32) (Mail, error)

func (*Queries) TestConnection

func (db *Queries) TestConnection(dsn string) error

function to make sure we can connect to database, test with retries

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SelectAllMailsParams

type SelectAllMailsParams struct {
	Limit  int32
	Offset int32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL