Documentation ¶
Index ¶
- func NewBinding() (*astReader, error)
- type Entity
- type Field
- type GoGenerator
- func (gen *GoGenerator) BindingFiles(forFile string, options generator.Options) []string
- func (GoGenerator) IsGeneratedFile(file string) bool
- func (GoGenerator) IsSourceFile(file string) bool
- func (gen *GoGenerator) ModelFile(forFile string, options generator.Options) 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 Property
- func (property *Property) AnnotatedType() string
- 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
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) // 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 StandaloneRelation *model.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 { ByValue bool // contains filtered or unexported fields }
func (*GoGenerator) BindingFiles ¶
func (gen *GoGenerator) BindingFiles(forFile string, options generator.Options) []string
BindingFiles returns names of binding files for the given entity file.
func (GoGenerator) IsGeneratedFile ¶
func (GoGenerator) IsGeneratedFile(file string) bool
func (GoGenerator) IsSourceFile ¶
func (GoGenerator) IsSourceFile(file string) bool
func (*GoGenerator) ModelFile ¶
func (gen *GoGenerator) ModelFile(forFile string, options generator.Options) 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 Property ¶
type Property struct { *binding.Field IsBasicType bool GoType string FbType string Converter *string // type casts for named types CastOnRead string CastOnWrite string GoField *Field // actual code field this property represents Entity *Entity // 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) 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.