[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
41
backend/ent/schema/post.go
Normal file
41
backend/ent/schema/post.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Post holds the schema definition for the Post entity.
|
||||
type Post struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Post.
|
||||
func (Post) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("status").
|
||||
Values("draft", "published", "archived").
|
||||
Default("draft"),
|
||||
field.String("slug").
|
||||
NotEmpty().
|
||||
Unique(),
|
||||
field.Time("created_at").
|
||||
Default(time.Now),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Post.
|
||||
func (Post) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("contents", PostContent.Type),
|
||||
edge.To("contributors", PostContributor.Type),
|
||||
edge.From("category", Category.Type).
|
||||
Ref("posts").
|
||||
Unique(),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue