db

package
v0.0.0-...-d239520 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatePackageParams

type CreatePackageParams struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Price         int64  `json:"price"`
	StripePriceID string `json:"stripe_price_id"`
}

type CreatePackageTxInput

type CreatePackageTxInput struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Price       int64  `json:"price"`
}

type CreatePackageTxResult

type CreatePackageTxResult struct {
	Message string `json:"message"`
}

type CreateSubscriptionUserParams

type CreateSubscriptionUserParams struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	StripeID string `json:"stripe_id"`
}

type CreateUserPackageParams

type CreateUserPackageParams struct {
	ID        string             `json:"id"`
	UserID    int64              `json:"user_id"`
	PackageID string             `json:"package_id"`
	Status    SubscriptionStatus `json:"status"`
	StartDate time.Time          `json:"start_date"`
	EndDate   time.Time          `json:"end_date"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetUserPackagesRow

type GetUserPackagesRow struct {
	ID            string             `json:"id"`
	UserID        int64              `json:"user_id"`
	PackageID     string             `json:"package_id"`
	Status        SubscriptionStatus `json:"status"`
	StartDate     time.Time          `json:"start_date"`
	EndDate       time.Time          `json:"end_date"`
	ID_2          int64              `json:"id_2"`
	Username      string             `json:"username"`
	Email         string             `json:"email"`
	StripeID      string             `json:"stripe_id"`
	CreatedAt     time.Time          `json:"created_at"`
	ID_3          string             `json:"id_3"`
	Name          string             `json:"name"`
	Description   string             `json:"description"`
	Price         int64              `json:"price"`
	StripePriceID string             `json:"stripe_price_id"`
}

type NullSubscriptionStatus

type NullSubscriptionStatus struct {
	SubscriptionStatus SubscriptionStatus
	Valid              bool // Valid is true if SubscriptionStatus is not NULL
}

func (*NullSubscriptionStatus) Scan

func (ns *NullSubscriptionStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullSubscriptionStatus) Value

func (ns NullSubscriptionStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Package

type Package struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Price         int64  `json:"price"`
	StripePriceID string `json:"stripe_price_id"`
}

type Querier

type Querier interface {
	CreatePackage(ctx context.Context, arg CreatePackageParams) (Package, error)
	CreateSubscriptionUser(ctx context.Context, arg CreateSubscriptionUserParams) (User, error)
	CreateUserPackage(ctx context.Context, arg CreateUserPackageParams) (UsersPackage, error)
	DeletePackage(ctx context.Context, id string) error
	DeleteSubscriptionUser(ctx context.Context, id int64) error
	DeleteUserPackage(ctx context.Context, id string) error
	GetPackage(ctx context.Context, id string) (Package, error)
	GetPackages(ctx context.Context) ([]Package, error)
	GetSubscriptionUserByStripeId(ctx context.Context, stripeID string) (User, error)
	GetSubscriptionUsers(ctx context.Context) ([]User, error)
	GetUserPackages(ctx context.Context) ([]GetUserPackagesRow, error)
	UpdatePackage(ctx context.Context, arg UpdatePackageParams) (Package, error)
	UpdateSubscriptionUser(ctx context.Context, arg UpdateSubscriptionUserParams) (User, error)
	UpdateUserPackage(ctx context.Context, arg UpdateUserPackageParams) (UsersPackage, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreatePackage

func (q *Queries) CreatePackage(ctx context.Context, arg CreatePackageParams) (Package, error)

func (*Queries) CreateSubscriptionUser

func (q *Queries) CreateSubscriptionUser(ctx context.Context, arg CreateSubscriptionUserParams) (User, error)

func (*Queries) CreateUserPackage

func (q *Queries) CreateUserPackage(ctx context.Context, arg CreateUserPackageParams) (UsersPackage, error)

func (*Queries) DeletePackage

func (q *Queries) DeletePackage(ctx context.Context, id string) error

func (*Queries) DeleteSubscriptionUser

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

func (*Queries) DeleteUserPackage

func (q *Queries) DeleteUserPackage(ctx context.Context, id string) error

func (*Queries) GetPackage

func (q *Queries) GetPackage(ctx context.Context, id string) (Package, error)

func (*Queries) GetPackages

func (q *Queries) GetPackages(ctx context.Context) ([]Package, error)

func (*Queries) GetSubscriptionUserByStripeId

func (q *Queries) GetSubscriptionUserByStripeId(ctx context.Context, stripeID string) (User, error)

func (*Queries) GetSubscriptionUsers

func (q *Queries) GetSubscriptionUsers(ctx context.Context) ([]User, error)

func (*Queries) GetUserPackages

func (q *Queries) GetUserPackages(ctx context.Context) ([]GetUserPackagesRow, error)

func (*Queries) UpdatePackage

func (q *Queries) UpdatePackage(ctx context.Context, arg UpdatePackageParams) (Package, error)

func (*Queries) UpdateSubscriptionUser

func (q *Queries) UpdateSubscriptionUser(ctx context.Context, arg UpdateSubscriptionUserParams) (User, error)

func (*Queries) UpdateUserPackage

func (q *Queries) UpdateUserPackage(ctx context.Context, arg UpdateUserPackageParams) (UsersPackage, error)

func (*Queries) WithTx

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

type Store

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

func (*Store) CreatePackageTx

func (s *Store) CreatePackageTx(ctx context.Context, args CreatePackageTxInput) (CreatePackageTxResult, error)

func (*Store) SubscribePackageTx

func (s *Store) SubscribePackageTx(ctx context.Context, args SubscribePackageTxInput) (SubscribePackageTxOutput, error)

type SubscribePackageTxInput

type SubscribePackageTxInput struct {
	CustomerID            string
	SubscriptionPackageID string
}

type SubscribePackageTxOutput

type SubscribePackageTxOutput struct {
	Message string
}

type SubscriptionStatus

type SubscriptionStatus string
const (
	SubscriptionStatusActive   SubscriptionStatus = "active"
	SubscriptionStatusInactive SubscriptionStatus = "inactive"
)

func (*SubscriptionStatus) Scan

func (e *SubscriptionStatus) Scan(src interface{}) error

type TxSubscriptionsStore

type TxSubscriptionsStore interface {
	Querier
	CreatePackageTx(ctx context.Context, args CreatePackageTxInput) (CreatePackageTxResult, error)
	SubscribePackageTx(ctx context.Context, args SubscribePackageTxInput) (SubscribePackageTxOutput, error)
}

func NewStore

func NewStore(db *sql.DB) TxSubscriptionsStore

type UpdatePackageParams

type UpdatePackageParams struct {
	Name        sql.NullString `json:"name"`
	Description sql.NullString `json:"description"`
	Price       sql.NullInt64  `json:"price"`
	ID          string         `json:"id"`
}

type UpdateSubscriptionUserParams

type UpdateSubscriptionUserParams struct {
	Username sql.NullString `json:"username"`
	Email    sql.NullString `json:"email"`
	StripeID sql.NullString `json:"stripe_id"`
	ID       int64          `json:"id"`
}

type UpdateUserPackageParams

type UpdateUserPackageParams struct {
	PackageID sql.NullString         `json:"package_id"`
	Status    NullSubscriptionStatus `json:"status"`
	StartDate sql.NullTime           `json:"start_date"`
	EndDate   sql.NullTime           `json:"end_date"`
	ID        string                 `json:"id"`
}

type User

type User struct {
	ID        int64     `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	StripeID  string    `json:"stripe_id"`
	CreatedAt time.Time `json:"created_at"`
}

type UsersPackage

type UsersPackage struct {
	ID        string             `json:"id"`
	UserID    int64              `json:"user_id"`
	PackageID string             `json:"package_id"`
	Status    SubscriptionStatus `json:"status"`
	StartDate time.Time          `json:"start_date"`
	EndDate   time.Time          `json:"end_date"`
}

Jump to

Keyboard shortcuts

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