ent: github.com/facebookincubator/ent/entc/load Index | Files | Directories

package load

import "github.com/facebookincubator/ent/entc/load"

Package load is the interface for loading schema package into a Go program.


Package Files

load.go schema.go

func MarshalSchema Uses

func MarshalSchema(schema ent.Interface) (b []byte, err error)

MarshalSchema encode the ent.Schema interface into a JSON that can be decoded into the Schema object object.

type Config Uses

type Config struct {
    // Path is the path for the schema package.
    Path string
    // Names are the schema names to run the code generation on.
    // Empty means all schemas in the directory.
    Names []string

Config holds the configuration for package building.

func (*Config) Load Uses

func (c *Config) Load() (*SchemaSpec, error)

Load loads the schemas package and build the Go plugin with this info.

type Edge Uses

type Edge struct {
    Name       string           `json:"name,omitempty"`
    Type       string           `json:"type,omitempty"`
    Tag        string           `json:"tag,omitempty"`
    RefName    string           `json:"ref_name,omitempty"`
    Ref        *Edge            `json:"ref,omitempty"`
    Unique     bool             `json:"unique,omitempty"`
    Inverse    bool             `json:"inverse,omitempty"`
    Required   bool             `json:"required,omitempty"`
    StorageKey *edge.StorageKey `json:"storage_key,omitempty"`

Edge represents an ent.Edge that was loaded from a complied user package.

func NewEdge Uses

func NewEdge(ed *edge.Descriptor) *Edge

NewEdge creates an loaded edge from edge descriptor.

type Field Uses

type Field struct {
    Name          string            `json:"name,omitempty"`
    Info          *field.TypeInfo   `json:"type,omitempty"`
    Tag           string            `json:"tag,omitempty"`
    Size          *int64            `json:"size,omitempty"`
    Enums         []string          `json:"enums,omitempty"`
    Unique        bool              `json:"unique,omitempty"`
    Nillable      bool              `json:"nillable,omitempty"`
    Optional      bool              `json:"optional,omitempty"`
    Default       bool              `json:"default,omitempty"`
    DefaultValue  interface{}       `json:"default_value,omitempty"`
    UpdateDefault bool              `json:"update_default,omitempty"`
    Immutable     bool              `json:"immutable,omitempty"`
    Validators    int               `json:"validators,omitempty"`
    StorageKey    string            `json:"storage_key,omitempty"`
    Position      *Position         `json:"position,omitempty"`
    Sensitive     bool              `json:"sensitive,omitempty"`
    SchemaType    map[string]string `json:"schema_type,omitempty"`

Field represents an ent.Field that was loaded from a complied user package.

func NewField Uses

func NewField(fd *field.Descriptor) (*Field, error)

NewField creates an loaded field from field descriptor.

type Index Uses

type Index struct {
    Unique     bool     `json:"unique,omitempty"`
    Edges      []string `json:"edges,omitempty"`
    Fields     []string `json:"fields,omitempty"`
    StorageKey string   `json:"storage_key,omitempty"`

Index represents an ent.Index that was loaded from a complied user package.

func NewIndex Uses

func NewIndex(idx *index.Descriptor) *Index

NewIndex creates an loaded index from index descriptor.

type Position Uses

type Position struct {
    Index      int  // Field index in the field list.
    MixedIn    bool // Indicates if the field was mixed-in.
    MixinIndex int  // Mixin index in the mixin list.

Position describes a field position in the schema.

type Schema Uses

type Schema struct {
    Name    string      `json:"name,omitempty"`
    Config  ent.Config  `json:"config,omitempty"`
    Edges   []*Edge     `json:"edges,omitempty"`
    Fields  []*Field    `json:"fields,omitempty"`
    Indexes []*Index    `json:"indexes,omitempty"`
    Hooks   []*Position `json:"hooks,omitempty"`
    Policy  bool        `json:"policy,omitempty"`

Schema represents an ent.Schema that was loaded from a complied user package.

func UnmarshalSchema Uses

func UnmarshalSchema(buf []byte) (*Schema, error)

UnmarshalSchema decodes the given buffer to a loaded schema.

type SchemaSpec Uses

type SchemaSpec struct {
    // Schemas are the schema descriptors.
    Schemas []*Schema
    // PkgPath is the package path of the schema.
    PkgPath string

A SchemaSpec holds an ent.schema package that created by Load.


internalPackage internal Code generated by go-bindata.

Package load imports 23 packages (graph) and is imported by 2 packages. Updated 2020-07-04. Refresh now. Tools for package owners.