Files
ent/ent.go
Ariel Mashraki 52292557f6 entc/indexes: inverse only restriction applies only on O2O relation
Reviewed By: alexsn

Differential Revision: D17004823

fbshipit-source-id: 08b62960b447a157419dbeefd80ca1fcd29efd76
2019-08-25 06:41:14 -07:00

72 lines
1.6 KiB
Go

// Package ent is an interface package for the schemas that use entc.
package ent
import (
"github.com/facebookincubator/ent/schema/edge"
"github.com/facebookincubator/ent/schema/field"
)
type (
// The Interface type describes the requirements for an exported type defined in the schema package.
// It functions as the interface between the user's schema types and codegen loader.
// Users should use the Schema type for embedding as follows:
//
// type T struct {
// ent.Schema
// }
//
Interface interface {
Type()
Fields() []Field
Edges() []Edge
Indexes() []Index
}
// Field is the interface for vertex and edges fields used by the code generation.
Field interface {
Tag() string
Name() string
Type() field.Type
IsUnique() bool
IsNillable() bool
IsOptional() bool
HasDefault() bool
IsImmutable() bool
Value() interface{}
Validators() []interface{}
}
// Edge is the interface for graph edges in the schema. It is used by the code generation.
Edge interface {
Tag() string
Type() string
Name() string
RefName() string
Assoc() *edge.Edge
IsUnique() bool
IsInverse() bool
IsRequired() bool
}
// Index is the interface for graph indexes in the schema. It is used by the code generation.
Index interface {
IsUnique() bool
EdgeNames() []string
FieldNames() []string
}
// Schema is the default implementation Interface.
Schema struct {
Interface
}
)
// Fields of the schema.
func (Schema) Fields() []Field { return nil }
// Edges of the schema.
func (Schema) Edges() []Edge { return nil }
// Indexes of the schema.
func (Schema) Indexes() []Index { return nil }