mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary: don't expose starage specific features in ent schema Reviewed By: a8m Differential Revision: D17111724 fbshipit-source-id: fca9e624b272c0db3fed14c511fa6cb07816a100
33 lines
738 B
Go
33 lines
738 B
Go
// Copyright 2019-present Facebook Inc. All rights reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
package schema
|
|
|
|
import (
|
|
"github.com/facebookincubator/ent"
|
|
"github.com/facebookincubator/ent/schema/field"
|
|
"github.com/facebookincubator/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(),
|
|
}
|
|
}
|