Files
ent/entc/load/testdata/valid/schema.go
Ariel Mashraki 61b8ccea4a entc/load: enable adding additional fields to the generated entities
Summary: In some cases (like xwf auth service), you want to add additional fields to the generated model.

Reviewed By: alexsn

Differential Revision: D17223674

fbshipit-source-id: fb4be71b388c6bd107e6bac242133c237fe25599
2019-09-08 08:05:13 -07:00

56 lines
1.0 KiB
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 valid
import (
"log"
"sync"
"github.com/facebookincubator/ent"
"github.com/facebookincubator/ent/schema/field"
)
// User holds the user schema.
type User struct {
ent.Schema
// add additional struct-only
// fields to the generated model.
Tenant string `json:"tenant,omitempty"`
Logger *log.Logger // Comment.
sync.Mutex
Ignored ent.Interface // Ignored comment.
}
func (User) Fields() []ent.Field {
return []ent.Field{
field.Int("age"),
field.String("name"),
}
}
// Group holds the group schema.
type Group struct {
ent.Schema
}
func (Group) Fields() []ent.Field {
return []ent.Field{
field.Time("expired_at"),
field.String("organization"),
}
}
// Tag holds the tag schema.
type Tag struct {
ent.Schema
}
func (Tag) Fields() []ent.Field {
return []ent.Field{
field.String("text"),
}
}