mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: alexsn Differential Revision: D16763332 fbshipit-source-id: e3e4279c62992de192464c3d3b1036c45687507c
29 lines
468 B
Go
29 lines
468 B
Go
package schema
|
|
|
|
import (
|
|
"fbc/ent"
|
|
"fbc/ent/schema/field"
|
|
"fbc/ent/schema/index"
|
|
)
|
|
|
|
// 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.Int32("age"),
|
|
field.String("name").MaxLen(10),
|
|
field.String("address").Optional(),
|
|
}
|
|
}
|
|
|
|
func (User) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("name", "address").
|
|
Unique(),
|
|
}
|
|
}
|