internal

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagGoen       = "goen"
	TagTable      = "table"
	TagView       = "view"
	TagPrimaryKey = "primary_key"
	TagColumn     = "column"
	TagForeignKey = "foreign_key"
	TagIgnore     = "ignore"
)

Variables

This section is empty.

Functions

func ColumnName

func ColumnName(field StructField) string

func EqColumnName

func EqColumnName(name string) func(StructField) bool

func EqFieldName

func EqFieldName(name string) func(StructField) bool

func FirstLookup

func FirstLookup(tag reflect.StructTag, names ...string) (string, bool)

func FirstNotEmpty

func FirstNotEmpty(strs ...string) string

func ForeignKey

func ForeignKey(field StructField) []string

func IsColumnField

func IsColumnField(field StructField) bool

func IsForeignKeyField

func IsForeignKeyField(field StructField) bool

func IsIgnoredField

func IsIgnoredField(field StructField) bool

func IsManyToOneField

func IsManyToOneField(field StructField) bool

func IsOneToManyField

func IsOneToManyField(field StructField) bool

func IsPrimaryKeyField

func IsPrimaryKeyField(field StructField) bool

func IsViewStruct

func IsViewStruct(strct Struct) bool

func OmitEmpty

func OmitEmpty(field StructField) bool

func ReferenceKey

func ReferenceKey(field StructField) []string

func TableName

func TableName(strct Struct) string

Types

type ColumnSpec

type ColumnSpec string

struct tag example:

`primary_key:""`
`primary_key:"col"`
`primary_key:"col,omitempty"`
`primary_key:",omitempty"`
`primary_key:","`
`column:""`
`column:"col"`
`column:"col,omitempty"`
`column:",omitempty"`
`column:","`

func (ColumnSpec) Name

func (s ColumnSpec) Name() string

func (ColumnSpec) OmitEmpty

func (s ColumnSpec) OmitEmpty() bool

type ForeignKeySpec

type ForeignKeySpec string

struct tag example:

`foreign_key:"col1,col2"`
  => foreign key (col1, col2) references another(col1, col2)
`foreign_key:"col1,col2:col3"`
  => foreign key (col1, col2) references another(col1, col3)

func (ForeignKeySpec) ChildKey

func (s ForeignKeySpec) ChildKey() []string

ChildKey is the column or set of columns in the child table that are constrained by the foreign key constraint and which hold the REFERENCES clause.

func (ForeignKeySpec) ParentKey

func (s ForeignKeySpec) ParentKey() []string

ParentKey is the column or set of columns in the parent table that the foreign key constraint refers to.

type Struct

type Struct interface {
	Name() string

	Fields() []StructField

	Value() interface{}
}

Struct represents go struct type info.

func NewStructFromAST

func NewStructFromAST(pkg *ast.Package, file *ast.File, obj *ast.Object) Struct

func NewStructFromReflect

func NewStructFromReflect(typ reflect.Type) Struct

type StructField

type StructField interface {
	Name() string

	Type() Type

	Tag() reflect.StructTag

	Value() interface{}
}

StructField represents go struct field info.

func FieldByFunc

func FieldByFunc(fields []StructField, fn func(StructField) bool) (StructField, bool)

func FieldsByFunc

func FieldsByFunc(fields []StructField, fn func(StructField) bool) (filtered []StructField)

type TableSpec

type TableSpec string

func (TableSpec) Name

func (s TableSpec) Name() string

func (TableSpec) ReadOnly

func (s TableSpec) ReadOnly() bool

type Type

type Type interface {
	fmt.Stringer

	Name() string

	// original package path.
	// like github.com/kamichidu/goen, reflect or empty.
	PkgPath() string

	Kind() reflect.Kind

	Elem() Type

	NewStruct() Struct

	Value() interface{}
}

Type represents go type info.

type TypeAlternator

type TypeAlternator interface {
	// stringify with alternative package name.
	// e.g. time.Time => timeAlt.Time
	StringWithPkgName(pkgName string) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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