entc

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package entc provides an interface for interacting with entc (ent codegen) as a package rather than an executable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(schemaPath string, cfg *gen.Config, options ...Option) (err error)

Generate runs the codegen on the schema path. The default target directory for the assets, is one directory above the schema path. Hence, if the schema package resides in "<project>/ent/schema", the base directory for codegen will be "<project>/ent".

If no storage driver provided by option, SQL driver will be used.

entc.Generate("./ent/path", &gen.Config{
	Header: "// Custom header",
	IDType: &field.TypeInfo{Type: field.TypeInt},
})

func LoadGraph

func LoadGraph(schemaPath string, cfg *gen.Config) (*gen.Graph, error)

LoadGraph loads the schema package from the given schema path, and constructs a *gen.Graph.

Types

type Option

type Option func(*gen.Config) error

Option allows for managing codegen configuration using functional options.

func FeatureNames added in v0.5.0

func FeatureNames(names ...string) Option

FeatureNames enables sets of features by their names.

func Storage

func Storage(typ string) Option

Storage sets the storage-driver type to support by the codegen.

func TemplateDir

func TemplateDir(path string) Option

TemplateDir parses the template definitions from the files in the directory and associates the resulting templates with codegen templates.

func TemplateFiles

func TemplateFiles(filenames ...string) Option

TemplateFiles parses the named files and associates the resulting templates with codegen templates.

func TemplateGlob

func TemplateGlob(pattern string) Option

TemplateGlob parses the template definitions from the files identified by the pattern and associates the resulting templates with codegen templates.

Directories

Path Synopsis
gen
Package gen is the interface for generating loaded schemas into a Go package.
Package gen is the interface for generating loaded schemas into a Go package.
internal
Package internal Code generated by go-bindata.
Package internal Code generated by go-bindata.
integration
ent
Package load is the interface for loading schema package into a Go program.
Package load is the interface for loading schema package into a Go program.
internal
Package internal Code generated by go-bindata.
Package internal Code generated by go-bindata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL