Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Post ¶
type Post struct {
goodm.Model `bson:",inline"`
Title string `bson:"title" goodm:"required"`
Body string `bson:"body" goodm:"required"`
Author bson.ObjectID `bson:"author" goodm:"required,index,ref=users"`
Status Status `bson:"status" goodm:"enum=draft|published|archived,default=draft"`
Tags []string `bson:"tags" goodm:"index"`
}
Post is an example model for blog posts.
func (*Post) BeforeCreate ¶
BeforeCreate sets timestamps on new posts.
func (*Post) BeforeSave ¶
BeforeSave updates the UpdatedAt timestamp.
func (*Post) Indexes ¶
func (p *Post) Indexes() []goodm.CompoundIndex
Indexes returns compound indexes for the Post model.
type User ¶
type User struct {
goodm.Model `bson:",inline"`
Email string `bson:"email" goodm:"unique,index,required"`
Name string `bson:"name" goodm:"required,immutable"`
Role Role `bson:"role" goodm:"enum=admin|user|mod,default=user"`
Age int `bson:"age" goodm:"min=13,max=120"`
Profile bson.ObjectID `bson:"profile" goodm:"ref=profiles"`
Verified bool `bson:"verified" goodm:"default=false"`
}
User is an example model demonstrating goodm schema features.
func (*User) BeforeCreate ¶
BeforeCreate sets default timestamps.
func (*User) Indexes ¶
func (u *User) Indexes() []goodm.CompoundIndex
Indexes returns compound indexes for the User model.
Click to show internal directories.
Click to hide internal directories.