at main 939 B view raw
1package schema 2 3import ( 4 "time" 5 6 "entgo.io/ent" 7 "entgo.io/ent/schema/field" 8 "entgo.io/ent/schema/index" 9 10 "tangled.sh/seiso.moe/aletheia.directory/pkg/plc" 11) 12 13type Operation struct { 14 ent.Schema 15} 16 17func (Operation) Fields() []ent.Field { 18 return []ent.Field{ 19 field.String("did"). 20 NotEmpty(). 21 Comment("Decentralized identifier"), 22 field.JSON("operation", plc.PLCOperation{}). 23 Comment("PLC operation data with proper typing"), 24 field.String("cid"). 25 NotEmpty(). 26 Comment("Content identifier"), 27 field.Bool("nullified"). 28 Default(false). 29 Comment("Whether the operation is nullified"), 30 field.Time("created_at"). 31 Default(time.Now). 32 Comment("Operation creation timestamp"), 33 } 34} 35 36func (Operation) Edges() []ent.Edge { 37 return nil 38} 39 40func (Operation) Indexes() []ent.Index { 41 return []ent.Index{ 42 index.Fields("did", "cid"). 43 Unique(), 44 index.Fields("created_at"), 45 index.Fields("did", "created_at"), 46 } 47}