Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct { gorm.Model Name string `gorm:"type:varchar(160);not null;uniqueIndex"` // "shoe1.jpg", "shoe2.jpg", ... Category string `gorm:"type:varchar(100);not null"` // "image", "downloadable", ... FileBlob []byte `gorm:"type:blob;not null"` Type string `gorm:"type:varchar(100);not null"` // "image/jpeg", "application/pdf", ... Extension string `gorm:"type:varchar(10);not null"` // "jpg", "png", "pdf", ... ProductID uint `gorm:"index;not null"` // the product this file belongs to }
type Order ¶
type Order struct { gorm.Model ExternalId string `json:"external_id" gorm:"unique;not null"` // from NOWPayments UserId uint `json:"user_id" gorm:"not null"` // the user who made the payment Status OrderStatus `json:"status" gorm:"not null"` // waiting, confirming, confirmed, sending, partially_paid, finished, failed, expired ProductId uint `json:"product_id" gorm:"not null"` // the product the user bought PriceAmount float64 `json:"price_amount" gorm:"not null"` // the amount the user paid (it's important to store because prices can change) PriceCurrency string `json:"price_currency" gorm:"not null"` // the currency in which we denominate the amount (e.g. usd) InvoiceUrl string `json:"invoice_url" gorm:"unique;not null"` // from NOWPayments }
type OrderStatus ¶
type OrderStatus string
const ( Waiting OrderStatus = "waiting" Confirming OrderStatus = "confirming" Confirmed OrderStatus = "confirmed" Sending OrderStatus = "sending" PartiallyPaid OrderStatus = "partially_paid" Finished OrderStatus = "finished" Failed OrderStatus = "failed" Expired OrderStatus = "expired" )
type Post ¶
type Product ¶
type Product struct { gorm.Model Name string `gorm:"type:varchar(160);not null;uniqueIndex"` // "Shoe #1", "Shoe #2", ... Description string `gorm:"type:text;not null"` // "A very nice shoe", ... Files []File `gorm:"foreignKey:ProductID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // 1 to many; downloadables, ... Images []File `gorm:"foreignKey:ProductID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // 1 to many; images for the product, ... PriceAmount float64 `gorm:"type:decimal(10,2);not null"` // 100.00 PriceCurrency string `gorm:"type:varchar(3);not null"` // usd, eur, ... }
func (*Product) Create ¶
make sure to put this behind role permissions so only admins can create plans
type Token ¶
For magic link login, but could also help with email verification, password reset if that was needed. It's meant as a way to verify that the user has access to the email of the account.
func (*Token) Create ¶
Note that this generates a random hashed token value. The unhashed value is returned for use in the email link.
Click to show internal directories.
Click to hide internal directories.