Documentation
¶
Index ¶
- func NewBinding() (*astReader, error)
- type Entity
- type Field
- type GoGenerator
- func (GoGenerator) BindingFile(forFile string) string
- func (GoGenerator) IsGeneratedFile(file string) bool
- func (GoGenerator) ModelFile(forFile string) string
- func (goGen *GoGenerator) ParseSource(sourceFile string) (*model.ModelInfo, error)
- func (goGen *GoGenerator) WriteBindingFiles(sourceFile string, options generator.Options, mergedModel *model.ModelInfo) error
- func (goGen *GoGenerator) WriteModelBindingFile(options generator.Options, modelInfo *model.ModelInfo) error
- type Identifier
- type Index
- type Property
- func (property *Property) AnnotatedType() string
- func (property *Property) FbSlot() int
- func (property *Property) FbvTableOffset() uint16
- func (property *Property) Merge(mProperty *model.Property) model.PropertyMeta
- func (property *Property) ObTypeString() string
- func (property *Property) Path() string
- func (property *Property) TplReadValue(objVar, castType string) string
- func (property *Property) TplSetAndReturn(objVar, castType, rhs string) string
- type StandaloneRelation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBinding ¶
func NewBinding() (*astReader, error)
Types ¶
type Entity ¶
type Entity struct {
*binding.Object
Fields []*Field // the tree of struct fields (necessary for embedded structs)
// TODO remove these
Relations map[string]*StandaloneRelation
// contains filtered or unexported fields
}
Entity holds the model information necessary to generate the binding code
func (*Entity) HasLazyLoadedRelations ¶
HasLazyLoadedRelations called from the template.
func (*Entity) HasNonIdProperty ¶
HasNonIdProperty called from the template. The goal is to void GO error "variable declared and not used"
func (*Entity) HasRelations ¶
HasRelations called from the template.
type Field ¶
type Field struct {
Entity *Entity // parent entity
Name string
Type string
IsPointer bool
Property *Property // nil if it's an embedded struct
Fields []*Field // inner fields, nil if it's a property
SimpleRelation string
StandaloneRelation *StandaloneRelation // to-many relation stored as a standalone relation in the model
IsLazyLoaded bool // only standalone (to-many) relations currently support lazy loading
Meta *Field // self reference for recursive ".Meta.Fields" access in the template
// contains filtered or unexported fields
}
Field is a field in an entity-struct. Not all fields become properties (e.g. to-many relations don't have a property)
func (*Field) HasLazyLoadedRelations ¶
HasLazyLoadedRelations called from the template.
func (*Field) HasPointersInPath ¶
HasPointersInPath checks whether there are any pointer-based fields in the path. Called from the template.
func (*Field) HasRelations ¶
HasRelations called from the template.
type GoGenerator ¶
type GoGenerator struct {
// contains filtered or unexported fields
}
func (GoGenerator) BindingFile ¶ added in v0.9.1
func (GoGenerator) BindingFile(forFile string) string
BindingFile returns a name of the binding file for the given entity file.
func (GoGenerator) IsGeneratedFile ¶
func (GoGenerator) IsGeneratedFile(file string) bool
func (GoGenerator) ModelFile ¶ added in v0.9.1
func (GoGenerator) ModelFile(forFile string) string
ModelFile returns the model GO file for the given JSON info file path
func (*GoGenerator) ParseSource ¶
func (goGen *GoGenerator) ParseSource(sourceFile string) (*model.ModelInfo, error)
func (*GoGenerator) WriteBindingFiles ¶
func (*GoGenerator) WriteModelBindingFile ¶
type Identifier ¶
type Identifier struct {
Id id
Uid uid
}
Identifier combines DB ID and UID into a single structure
type Index ¶
type Index struct {
Identifier
}
Index holds information for creating an indexed field in DB
type Property ¶
type Property struct {
*binding.Field
GoType string
FbType string
// TODO remove these
Identifier
IsPointer bool
Converter *string
// type casts for named types
CastOnRead string
CastOnWrite string
GoField *Field // actual code field this property represents
Entity *Entity
UidRequest bool
// contains filtered or unexported fields
}
Property represents a mapping between a struct field and a DB field
func (*Property) AnnotatedType ¶
AnnotatedType returns "type" annotation value
func (*Property) FbSlot ¶
FbSlot is called from the template. It calculates flatbuffers slot number.
func (*Property) FbvTableOffset ¶
TODO moved to model.Property FbvTableOffset calculates flatbuffers vTableOffset. Called from the template.
func (*Property) Merge ¶
func (property *Property) Merge(mProperty *model.Property) model.PropertyMeta
Merge implements model.PropertyMeta interface
func (*Property) ObTypeString ¶
ObTypeString is called from the template
func (*Property) Path ¶
Path is called from the template. It returns full path to the property (in embedded struct).
func (*Property) TplReadValue ¶
TplReadValue returns a code to read the property value on a given object.
func (*Property) TplSetAndReturn ¶
TplSetAndReturn returns a code to write the property value on a given object.
type StandaloneRelation ¶
type StandaloneRelation struct {
Identifier
Target struct {
Identifier
Name string
IsPointer bool
}
Name string
UidRequest bool
}
StandaloneRelation contains information about a "to-many" relation