Documentation
¶
Overview ¶
Package generator provides tools to generate ObjectBox entity bindings between GO structs & ObjectBox schema
Index ¶
- Constants
- func BindingFile(sourceFile string) string
- 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
- type Relation
- type StandaloneRelation
Constants ¶
View Source
const ( /// One long property on an entity must be the ID PropertyFlagId = 1 /// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null) PropertyFlagNonPrimitiveType = 2 /// Unused yet PropertyFlagNotNull = 4 PropertyFlagIndexed = 8 PropertyFlagReserved = 16 /// Unused yet: Unique index PropertyFlagUnique = 32 /// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse) PropertyFlaIdMonotonicSequence = 64 /// Allow IDs to be assigned by the developer PropertyFlagIdSelfAssignable = 128 /// Unused yet PropertyFlagIndexPartialSkipNull = 256 /// Unused yet, used by References for 1) back-references and 2) to clear references to deleted objects (required for ID reuse) PropertyFlagIndexPartialSkipZero = 512 /// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations PropertyFlagVirtual = 1024 /// Index uses a 32 bit hash instead of the value /// (32 bits is shorter on disk, runs well on 32 bit systems, and should be OK even with a few collisions) PropertyFlagIndexHash = 2048 /// Index uses a 64 bit hash instead of the value /// (recommended mostly for 64 bit machines with values longer >200 bytes; small values are faster with a 32 bit hash) PropertyFlagIndexHash64 = 4096 /// The actual type of the variable is unsigned (used in combination with numeric OBXPropertyType_*) PropertyFlagUnsigned = 8192 )
View Source
const ( PropertyTypeBool = 1 PropertyTypeByte = 2 PropertyTypeShort = 3 PropertyTypeChar = 4 PropertyTypeInt = 5 PropertyTypeLong = 6 PropertyTypeFloat = 7 PropertyTypeDouble = 8 PropertyTypeString = 9 PropertyTypeDate = 10 PropertyTypeRelation = 11 PropertyTypeByteVector = 23 PropertyTypeStringVector = 30 )
View Source
const Version = 3
Variables ¶
This section is empty.
Functions ¶
func BindingFile ¶
func ModelInfoFile ¶
Types ¶
type Annotation ¶
type Annotation struct {
Value string
}
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
}
func (*Entity) HasLazyLoadedRelations ¶ added in v1.0.0
func (*Entity) HasNonIdProperty ¶
called from the template avoid GO error "variable declared and not used"
func (*Entity) HasRelations ¶ added in v0.9.0
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
}
func (*Field) HasLazyLoadedRelations ¶ added in v1.0.0
func (*Field) HasRelations ¶ added in v0.9.0
type Identifier ¶ added in v0.9.0
type Identifier struct {
Id id
Uid uid
}
type Index ¶
type Index struct {
Identifier
}
type Property ¶
type Property struct {
Identifier
BaseName string // name in the containing struct (might be embedded)
Name string // prefixed name (unique)
ObName string // name of the field in DB
Annotations map[string]*Annotation
ObType int
ObFlags []int
GoType string
FbType string
IsPointer bool
Relation *Relation
Index *Index
Converter *string
// type casts for named types
CastOnRead string
CastOnWrite string
// contains filtered or unexported fields
}
func (*Property) FbvTableOffset ¶
calculates flatbuffers vTableOffset called from the template
func (*Property) ObFlagsCombined ¶ added in v1.0.0
func (*Property) ObTypeString ¶ added in v1.0.0
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
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.