mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
db optimize
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Epidodes holds the schema definition for the Epidodes entity.
|
||||
type Epidodes struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Epidodes.
|
||||
func (Epidodes) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("series_id"),
|
||||
field.Int("season_number"),
|
||||
field.Int("episode_number"),
|
||||
field.String("title"),
|
||||
field.String("overview"),
|
||||
field.String("air_date"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Epidodes.
|
||||
func (Epidodes) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
34
ent/schema/episode.go
Normal file
34
ent/schema/episode.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Episode holds the schema definition for the Epidodes entity.
|
||||
type Episode struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Episode.
|
||||
func (Episode) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
//field.Int("series_id"),
|
||||
field.Int("season_number"),
|
||||
field.Int("episode_number"),
|
||||
field.String("title"),
|
||||
field.String("overview"),
|
||||
field.String("air_date"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Episode.
|
||||
func (Episode) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("series", Series.Type).
|
||||
Ref("episodes").
|
||||
Unique(),
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -17,7 +18,7 @@ func (Series) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("tmdb_id"),
|
||||
field.String("imdb_id").Optional(),
|
||||
field.String("title"),
|
||||
field.String("name"),
|
||||
field.String("original_name"),
|
||||
field.String("overview"),
|
||||
field.String("path"),
|
||||
@@ -28,5 +29,8 @@ func (Series) Fields() []ent.Field {
|
||||
|
||||
// Edges of the Series.
|
||||
func (Series) Edges() []ent.Edge {
|
||||
return nil
|
||||
return []ent.Edge{
|
||||
edge.To("episodes", Episode.Type),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user