generated from mikestefanello/pagoda
/
squeak.go
52 lines (47 loc) · 1012 Bytes
/
squeak.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/mixin"
"github.com/ahashim/web-server/types"
)
// Squeak holds the schema definition for the Squeak entity.
type Squeak struct {
ent.Schema
}
// Fields of the Squeak.
func (Squeak) Fields() []ent.Field {
return []ent.Field{
field.Int("block_number").
GoType(new(types.Uint256)).
SchemaType(map[string]string{
dialect.Postgres: "numeric(78, 0)",
}),
field.String("content").
Immutable().
MaxLen(256).
NotEmpty(),
}
}
// Edges of the Squeak.
func (Squeak) Edges() []ent.Edge {
return []ent.Edge{
edge.To("interactions", Interaction.Type),
edge.To("pool", Pool.Type).
Unique(),
edge.From("creator", User.Type).
Ref("created").
Unique(),
edge.From("owner", User.Type).
Ref("owned").
Unique(),
}
}
// Mixins of the Squeak.
func (Squeak) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.CreateTime{},
}
}