package schema import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "regexp" "time" ) // 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.String("email").Match(regexp.MustCompile(`[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$`)).Unique().Optional().Nillable(), field.String("cell_phone").Nillable(), field.String("first_name").MaxLen(150), field.String("last_name").MaxLen(255), field.Text("password").Optional().Nillable(), field.Bool("is_active").Default(false), field.Bool("is_admin").Default(false), field.Time("created_at").Default(time.Now), field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), field.Time("last_authentication_at").Optional(), } } // Edges of the User. func (User) Edges() []ent.Edge { return []ent.Edge{ edge.To("products", Product.Type), edge.To("domains", Domain.Type), edge.To("businesses", Business.Type), } }