models

package
v0.0.0-...-e406fe1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate    = errors.New("duplicate subscription")
	ErrInvalidInput = errors.New("invalid input")
)

Functions

This section is empty.

Types

type DB

type DB interface {
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

DB interface defines the database operations we need

type Subscription

type Subscription struct {
	ID        int64     `db:"id" json:"id"`
	Email     string    `db:"email" json:"email"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

Subscription represents a newsletter subscription

func (*Subscription) Validate

func (s *Subscription) Validate() error

Validate checks if the subscription data is valid

type SubscriptionStore

type SubscriptionStore interface {
	CreateSubscription(ctx context.Context, sub *Subscription) error
}

SubscriptionStore defines the interface for subscription storage operations

func NewSubscriptionStore

func NewSubscriptionStore(db DB) SubscriptionStore

NewSubscriptionStore creates a new subscription store

Jump to

Keyboard shortcuts

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