scheme

package
v0.0.0-...-4a94f85 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HasNoRel = 0

	Belongs = 1 << iota
	HasOne
	HasMany

	BelongsManyThrough
	BelongsOneThrough
	HasManyThrough
	HasOneThrough

	BelongsEmbed
	HasOneEmbed
	HasManyEmbed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Def

type Def Scheme

Def is responsible the define the metadata for the scheme

func (*Def) Done

func (d *Def) Done()

func (*Def) Field

func (def *Def) Field(fieldName string, dbName ...string) FieldDef

Field defines a schema field with the fieldName

func (*Def) Index

func (def *Def) Index(_typ string, _fields ...string) *Def

Index define a index type _typ on fields _fields

func (*Def) Meta

func (def *Def) Meta(meta ...interface{}) *Def

type Definer

type Definer interface {
	Def(*Def)
}

type Field

type Field struct {
	PrimaryKey bool // bool if the field is the primaryKey

	Name     string // the name of the field in the go Type
	RealName string // the name of the field in the database

	Type  reflect.Type // the type of the field
	Index []int        // the index of the field

	RelKind RelKind // Kind of relation, or HasNoRel for normal field
	RelDst  string  // the target fieldName in the target go Type

	RelSrc string // the source fieldName in the source go Type
	RelNs  string // the name of the namespace used to store the relations through

	Testers []validation.Tester // list of validators, to constrain the insert and update of values
	// contains filtered or unexported fields
}

Field holds metadata about the fields and the references

func (*Field) Meta

func (scheme *Field) Meta() []interface{}

Meta returns metadata stored during the field definition this metadata is intended to be used by the driver

type FieldDef

type FieldDef struct {
	// contains filtered or unexported fields
}

FieldDef holds methods

func (FieldDef) Belongs

func (f FieldDef) Belongs(args ...string) FieldDef

func (FieldDef) BelongsEmbed

func (f FieldDef) BelongsEmbed(args ...string) FieldDef

func (FieldDef) Field

func (def FieldDef) Field(name string, dbName ...string) FieldDef

func (FieldDef) HasMany

func (f FieldDef) HasMany(args ...string) FieldDef

func (FieldDef) HasManyEmbed

func (f FieldDef) HasManyEmbed(args ...string) FieldDef

func (FieldDef) HasOne

func (f FieldDef) HasOne(args ...string) FieldDef

func (FieldDef) HasOneEmbed

func (f FieldDef) HasOneEmbed(args ...string) FieldDef

HasOneEmbed creates a relation between the current field and his target field

func (FieldDef) Meta

func (f FieldDef) Meta(m ...interface{}) FieldDef

Meta adds special metadata to the field

func (FieldDef) PrimaryKey

func (f FieldDef) PrimaryKey() FieldDef

func (FieldDef) Validation

func (f FieldDef) Validation(testers ...validation.Tester) FieldDef

Validation adds validators to the field

type Index

type Index struct {
	Fields []string
	Type   string
}

Index abstract index definition

type RelKind

type RelKind int

type Scheme

type Scheme struct {
	PrimaryKey *Field
	Namespace  string

	Type reflect.Type
	// contains filtered or unexported fields
}

Scheme represents a database entity, fields and the references between different entities

func (*Scheme) FieldByName

func (scheme *Scheme) FieldByName(name string) (field *Field, found bool)

FieldByName returns a field by name

func (*Scheme) Fields

func (scheme *Scheme) Fields() []*Field

Fields returns the list of fields in the scheme

func (*Scheme) Indexes

func (scheme *Scheme) Indexes() []Index

Indexes returns the list of indexes in the scheme

func (*Scheme) Meta

func (scheme *Scheme) Meta() []interface{}

Meta returns metadata stored during the field definition this metadata is intended to be used by the driver

Jump to

Keyboard shortcuts

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