feat: community RPC 从内存存储迁移到 ent 数据库
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
type Comments struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Comments) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").Unique().Immutable(),
|
||||
field.Int64("post_id"),
|
||||
field.Int64("author_id"),
|
||||
field.String("content"),
|
||||
field.Int("like_count").Optional().Default(0),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("deleted_at").Optional().Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (Comments) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("post_id", "created_at"),
|
||||
index.Fields("author_id", "created_at"),
|
||||
}
|
||||
}
|
||||
|
||||
func (Comments) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user