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