Documentation ¶
Overview ¶
Package generator provides tools to generate ObjectBox entity bindings between GO structs & ObjectBox schema
Index ¶
- Constants
- func BindingFile(sourceFile string) string
- func Clean(path string) error
- func ModelFile(modelInfoFile string) string
- func ModelInfoFile(dir string) string
- func Process(sourceFile string, options Options) error
- type Annotation
- type Binding
- type Entity
- type Field
- type Identifier
- type Index
- type Options
- type Property
- func (property *Property) AnnotatedType() string
- func (property *Property) FbSlot() int
- func (property *Property) FbvTableOffset() uint16
- func (property *Property) IsId() bool
- func (property *Property) ObFlagsCombined() int
- 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 Relation
- type StandaloneRelation
Constants ¶
const Version = 5
Version specifies the current generator version. It is used to validate generated code compatibility and is increased when there are changes in the generated code. Internal generator changes that don't change the output do not cause an increase.
Variables ¶
This section is empty.
Functions ¶
func BindingFile ¶
BindingFile returns a name of the binding file for the given entity file.
func Clean ¶ added in v1.1.0
Clean removes generated files in the given path. Removes *.obx.go and objectbox-model.go but keeps objectbox-model.json
func ModelInfoFile ¶
ModelInfoFile returns the model info JSON file name in the given directory
Types ¶
type Binding ¶
type Binding struct { Package *types.Package Entities []*Entity Imports map[string]string // contains filtered or unexported fields }
Binding contains information about the processed set of Entities
type Entity ¶
type Entity struct { Identifier Name string Fields []*Field // the tree of struct fields (necessary for embedded structs) Properties []*Property IdProperty *Property LastPropertyId modelinfo.IdUid Relations map[string]*StandaloneRelation Annotations map[string]*Annotation // contains filtered or unexported fields }
Entity holds the model information necessary to generate the binding code
func (*Entity) HasLazyLoadedRelations ¶ added in v1.0.0
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 ¶ added in v0.9.0
HasRelations called from the template.
type Field ¶ added in v0.9.0
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 *Relation StandaloneRelation *StandaloneRelation // to-many relation stored as a standalone relation in the model IsLazyLoaded bool // only standalone (to-many) relations currently support lazy loading // 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 ¶ added in v1.0.0
HasLazyLoadedRelations called from the template.
func (*Field) HasPointersInPath ¶ added in v1.1.0
HasPointersInPath checks whether there are any pointer-based fields in the path. Called from the template.
func (*Field) HasRelations ¶ added in v0.9.0
HasRelations called from the template.
type Identifier ¶ added in v0.9.0
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 { Identifier Name string // prefixed name (unique) ObName string // name of the field in DB Annotations map[string]*Annotation ObType int GoType string FbType string IsPointer bool Relation *Relation Index *Index Converter *string // type casts for named types CastOnRead string CastOnWrite string Field *Field // actual code field this property represents // contains filtered or unexported fields }
Property represents a mapping between a struct field and a DB field
func (*Property) AnnotatedType ¶ added in v1.1.0
AnnotatedType returns "type" annotation value
func (*Property) FbSlot ¶
FbSlot is called from the template. It calculates flatbuffers slot number.
func (*Property) FbvTableOffset ¶
FbvTableOffset calculates flatbuffers vTableOffset. Called from the template.
func (*Property) IsId ¶ added in v1.1.0
IsId returns true if the given field is an ID. Called from the template.
func (*Property) ObFlagsCombined ¶ added in v1.0.0
ObFlagsCombined called from the template
func (*Property) ObTypeString ¶ added in v1.0.0
ObTypeString is called from the template
func (*Property) Path ¶ added in v0.9.0
Path is called from the template. It returns full path to the property (in embedded struct).
func (*Property) TplReadValue ¶ added in v1.1.0
TplReadValue returns a code to read the property value on a given object.
func (*Property) TplSetAndReturn ¶ added in v1.1.0
TplSetAndReturn returns a code to write the property value on a given object.
type Relation ¶
type Relation struct { Target struct { Name string } }
Relation contains information about a "to-one" relation
type StandaloneRelation ¶ added in v0.9.0
type StandaloneRelation struct { Identifier Target struct { Identifier Name string IsPointer bool } Name string // contains filtered or unexported fields }
StandaloneRelation contains information about a "to-many" relation