document

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDocument     = errors.New("not document")
	ErrUnknownProperty = errors.New("unknown property")
)
View Source
var (
	ErrInvalidField        = errors.New("invalid field")
	ErrOnlyOneAutoIncField = errors.New("only one autoinc field is allowed")
)

Functions

func GoNamePrivate

func GoNamePrivate(name string) string

func GoNamePublic

func GoNamePublic(name string) string

Types

type Document

type Document struct {
	Version    string     `yaml:"version"`
	Output     Output     `yaml:"output"`
	Generators Generators `yaml:"generators"`
	Imports    []*Import  `yaml:"imports"`
	Records    []*Record  `yaml:"records"`
}

func NewDocument

func NewDocument() *Document

func (*Document) UnmarshalYAML

func (doc *Document) UnmarshalYAML(value *yaml.Node) error

type Field

type Field struct {
	Record     *Record `yaml:"-"`
	GoName     string  `yaml:"go_name"`
	Name       string  `yaml:"name"`
	Type       string  `yaml:"type"`
	AutoInc    bool    `yaml:"auto_inc"`
	PrimaryKey bool    `yaml:"pk"`
	Tag        string  `yaml:"tag"`
}

Field represents a field in the yaml file.

func (*Field) UnmarshalYAML

func (field *Field) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML

type Generators

type Generators struct {
	Models      bool `yaml:"models"`
	Schema      bool `yaml:"schema"`
	Connections bool `yaml:"connections"`
	ResultSets  bool `yaml:"resultsets"`
	Stores      bool `yaml:"stores"`
	Queries     bool `yaml:"queries"`
}

type GoType

type GoType interface {
	// Package returns the original go package that this type came from.
	Package() string

	// Name is the go type name.
	Name() string
}

func NewGoType

func NewGoType(pkg, name string) GoType

NewGoType returns a new instance of a `GoType` interface with the package and name initialized.

The base implementation is a simple struct that keep only the required information for implementing `GoType`.

type Import

type Import struct {
	Name       string
	ImportPath string
}

func (*Import) String

func (i *Import) String() string

func (*Import) UnmarshalYAML

func (i *Import) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML

type Output

type Output struct {
	Package    string `yaml:"package"`
	Model      string `yaml:"model`
	Directory  string `yaml:"directory"`
	Schema     string `yaml:"schema"`
	Connection string `yaml:"connection"`
	ResultSet  string `yaml:"resultset"`
	Store      string `yaml:"store"`
	Query      string `yaml:"query"`
}

type Package

type Package struct {
	Name       string
	ImportPath string
	Directory  string
	Alias      string
}

Package will keep the information about some packages that will be needed for generation.

func (*Package) Equals

func (pkg *Package) Equals(b *Package) bool

func (*Package) Ref

func (pkg *Package) Ref(srcPkg *Package, t string) string

type Query

type Query struct {
	Type string
}

type Record

type Record struct {
	Document            *Document  `yaml:"-"`
	Schema              *Schema    `yaml:"-"`
	Query               *Query     `yaml:"-"`
	Store               *Store     `yaml:"-"`
	ResultSet           *ResultSet `yaml:"-"`
	Name                string     `yaml:"name"`
	TableName           string     `yaml:"table_name"`
	Documentation       []string   `yaml:"-"`
	Fields              []*Field   `yaml:"fields"`
	PrimaryKey          []*Field   `yaml:"-"`
	FieldAutoInc        *Field     `yaml:"-"`
	FieldsNameMaxLength int        `yaml:"-"`
	FieldsTypeMaxLength int        `yaml:"-"`
}

Record represents a record.

func (*Record) UnmarshalYAML

func (record *Record) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML

type ResultSet

type ResultSet struct {
	Type string
}

type Schema

type Schema struct {
	Name        string
	Type        string
	InternalRef string
}

type Store

type Store struct {
	Type string
}

Jump to

Keyboard shortcuts

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