-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
49 lines (44 loc) · 983 Bytes
/
user.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
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/cble-platform/cble/backend/ent/mixins"
"github.com/google/uuid"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.UUID{}).
Immutable().
Default(uuid.New),
field.String("username").
Unique(),
field.String("email"),
field.String("password").
Sensitive(),
field.String("first_name"),
field.String("last_name"),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("groups", Group.Type),
edge.From("deployments", Deployment.Type).
Ref("requester"),
edge.From("projects", Project.Type).
Ref("members").
Comment("Projects user is a member of"),
}
}
// Mixins of the User.
func (User) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.Timestamps{},
}
}