Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArticleGenerator ¶
func ArticleGenerator() interface{}
ArticleGenerator generator function for the Article model.
Be careful, this generator doesn't set the AuthorID!
Generate articles using the following:
database.NewFactory(model.ArticleGenerator).Generate(5)
func RateLimiterFunc ¶
func RateLimiterFunc(request *goyave.Request) ratelimiter.Config
RateLimiterFunc returns rate limiting configuration Anonymous users have a quota of 50 requests per minute while authenticated users are limited to 500 requests per minute.
func UserGenerator ¶
func UserGenerator() interface{}
UserGenerator generator function for the User model. Generate users using the following:
database.NewFactory(model.UserGenerator).Generate(5)
Types ¶
type Article ¶
type Article struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time Title string `gorm:"type:char(200);not null"` Contents string `gorm:"type:text;not null"` Slug string `gorm:"type:char(80);not null;unique;uniqueIndex"` AuthorID uint `json:"-"` Author *User `gorm:"constraint:OnDelete:CASCADE;" json:",omitempty"` }
Article represents an article posted by a user.
func (*Article) BeforeCreate ¶
BeforeCreate hook executed before a Article record is inserted in the database. Ensures the slug is up to date.
type User ¶
type User struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time Username string `gorm:"type:char(100);unique;uniqueIndex;not null"` Email string `gorm:"type:char(100);unique;uniqueIndex;not null" auth:"username"` Image null.String `gorm:"type:char(100);default:null" json:"-"` Password string `gorm:"type:char(60);not null" auth:"password" json:"-"` }
User represents a user.
func (*User) BeforeCreate ¶
BeforeCreate hook executed before a User record is inserted in the database. Ensures the password is encrypted using bcrypt, with the cost defined by the config entry "app.bcryptCost".