mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
Reviewed By: alexsn Differential Revision: D16763332 fbshipit-source-id: e3e4279c62992de192464c3d3b1036c45687507c
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
// Package ent is an interface package for the schemas that use entc.
|
|
package ent
|
|
|
|
import (
|
|
"fbc/ent/schema/edge"
|
|
"fbc/ent/schema/field"
|
|
)
|
|
|
|
type (
|
|
// Schema is the interface for describing an entity schema for entc.
|
|
Schema interface {
|
|
Type()
|
|
Edges() []Edge
|
|
Fields() []Field
|
|
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
|
|
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
|
|
Edge() string
|
|
Fields() []string
|
|
}
|
|
)
|
|
|
|
// DefaultSchema holds the default schema implementation.
|
|
var DefaultSchema defaultSchema
|
|
|
|
// defaultSchema is the default implementation for the schema.
|
|
type defaultSchema struct{ Schema }
|
|
|
|
func (defaultSchema) Edges() []Edge { return nil }
|
|
|
|
func (defaultSchema) Fields() []Field { return nil }
|
|
|
|
func (defaultSchema) Indexes() []Index { return nil }
|