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
Click to show internal directories.
Click to hide internal directories.