[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
45
backend/ent/schema/daily.go
Normal file
45
backend/ent/schema/daily.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"time"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Daily holds the schema definition for the Daily entity.
|
||||
type Daily struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Daily.
|
||||
func (Daily) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("id").
|
||||
Match(regexp.MustCompile(`^[0-9]{6}$`)).
|
||||
Unique().
|
||||
Immutable().
|
||||
NotEmpty().
|
||||
MaxLen(6).
|
||||
MinLen(6),
|
||||
field.String("image_url").
|
||||
NotEmpty(),
|
||||
field.Time("created_at").
|
||||
Default(time.Now),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Daily.
|
||||
func (Daily) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("category", Category.Type).
|
||||
Ref("daily_items").
|
||||
Unique().
|
||||
Required(),
|
||||
edge.To("contents", DailyContent.Type),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue