Documentation
¶
Index ¶
- Constants
- type Def
- type Definer
- type Field
- type FieldDef
- func (f FieldDef) Belongs(args ...string) FieldDef
- func (f FieldDef) BelongsEmbed(args ...string) FieldDef
- func (def FieldDef) Field(name string, dbName ...string) FieldDef
- func (f FieldDef) HasMany(args ...string) FieldDef
- func (f FieldDef) HasManyEmbed(args ...string) FieldDef
- func (f FieldDef) HasOne(args ...string) FieldDef
- func (f FieldDef) HasOneEmbed(args ...string) FieldDef
- func (f FieldDef) Meta(m ...interface{}) FieldDef
- func (f FieldDef) PrimaryKey() FieldDef
- func (f FieldDef) Validation(testers ...validation.Tester) FieldDef
- type Index
- type RelKind
- type Scheme
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
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
type FieldDef ¶
type FieldDef struct {
// contains filtered or unexported fields
}
FieldDef holds methods
func (FieldDef) BelongsEmbed ¶
func (FieldDef) HasManyEmbed ¶
func (FieldDef) HasOneEmbed ¶
HasOneEmbed creates a relation between the current field and his target field
func (FieldDef) PrimaryKey ¶
func (FieldDef) Validation ¶
func (f FieldDef) Validation(testers ...validation.Tester) FieldDef
Validation adds validators to the field
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 ¶
FieldByName returns a field by name
Click to show internal directories.
Click to hide internal directories.