Documentation ¶
Index ¶
- func Create(ctx context.Context, db sqlx.ExtContext, cart Cart) error
- func CreateItem(ctx context.Context, db sqlx.ExtContext, item Item) error
- func Delete(ctx context.Context, db sqlx.ExtContext, userID string) error
- func DeleteItem(ctx context.Context, db sqlx.ExtContext, userID string, courseID string) error
- func HandleCreateItem(db *sqlx.DB) web.Handler
- func HandleDelete(db *sqlx.DB) web.Handler
- func HandleDeleteItem(db *sqlx.DB) web.Handler
- func HandleShow(db *sqlx.DB) web.Handler
- type Cart
- type Item
- type ItemNew
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateItem ¶
CreateItem inserts a new item in the user's cart.
func DeleteItem ¶
DeleteItem drops an item from the user's cart.
func HandleCreateItem ¶
HandleCreateItem adds a new item in the user's cart.
func HandleDelete ¶
HandleDelete flushes the user's cart. It also drops all related items in cascade.
func HandleDeleteItem ¶
HandleDeleteItem deletes an item from the user's cart.
Types ¶
type Cart ¶
type Cart struct { UserID string `json:"-" db:"user_id"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` Version int `json:"-" db:"version"` Items []Item `json:"items" db:"-"` }
Cart models the users' carts. Each user can have only a cart at a time.
type Item ¶
type Item struct { UserID string `json:"-" db:"user_id"` CourseID string `json:"courseId" db:"course_id"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` }
Item models the item of a cart. A cart can have many items.
func FetchItems ¶
FetchItems returns all the user's cart items.
Click to show internal directories.
Click to hide internal directories.