objectbox-go: github.com/objectbox/objectbox-go/internal/generator/modelinfo Index | Files

package modelinfo

import "github.com/objectbox/objectbox-go/internal/generator/modelinfo"

Index

Package Files

entity.go fileio.go iduid.go model.go property.go relation.go relcycles.go

Constants

const (
    // ModelVersion specifies current version of the model JSON file generated
    ModelVersion = 5
)

type Entity Uses

type Entity struct {
    Id             IdUid                 `json:"id"`
    LastPropertyId IdUid                 `json:"lastPropertyId"`
    Name           string                `json:"name"`
    Properties     []*Property           `json:"properties"`
    Relations      []*StandaloneRelation `json:"relations,omitempty"`
    // contains filtered or unexported fields
}

Entity represents a DB entity

func CreateEntity Uses

func CreateEntity(model *ModelInfo, id Id, uid Uid) *Entity

CreateEntity constructs an Entity

func (*Entity) CreateProperty Uses

func (entity *Entity) CreateProperty() (*Property, error)

CreateProperty creates a property

func (*Entity) CreateRelation Uses

func (entity *Entity) CreateRelation() (*StandaloneRelation, error)

CreateRelation creates relation

func (*Entity) FindPropertyByName Uses

func (entity *Entity) FindPropertyByName(name string) (*Property, error)

FindPropertyByName finds a property by name

func (*Entity) FindPropertyByUid Uses

func (entity *Entity) FindPropertyByUid(uid Uid) (*Property, error)

FindPropertyByUid finds a property by Uid

func (*Entity) FindRelationByName Uses

func (entity *Entity) FindRelationByName(name string) (*StandaloneRelation, error)

FindRelationByName finds relation by name

func (*Entity) FindRelationByUid Uses

func (entity *Entity) FindRelationByUid(uid Uid) (*StandaloneRelation, error)

FindRelationByUid Finds relation by Uid

func (*Entity) RemoveProperty Uses

func (entity *Entity) RemoveProperty(property *Property) error

RemoveProperty removes a property

func (*Entity) RemoveRelation Uses

func (entity *Entity) RemoveRelation(relation *StandaloneRelation) error

RemoveRelation removes relation

func (*Entity) Validate Uses

func (entity *Entity) Validate() (err error)

Validate performs initial validation of loaded data so that it doesn't have to be checked in each function

type Id Uses

type Id = uint32

Id identifies a model element locally (e.g. property inside an entity)

type IdUid Uses

type IdUid string

IdUid represents a "ID:UID" string as used in the model jSON

func CreateIdUid Uses

func CreateIdUid(id Id, uid Uid) IdUid

CreateIdUid creates a string representation of ID and UID

func (*IdUid) Get Uses

func (str *IdUid) Get() (Id, Uid, error)

Get returns a pair of ID and UID

func (IdUid) GetId Uses

func (str IdUid) GetId() (Id, error)

GetId returns the ID part

func (*IdUid) GetUid Uses

func (str *IdUid) GetUid() (Uid, error)

GetUid returns the UID part

func (*IdUid) Validate Uses

func (str *IdUid) Validate() error

Validate performs initial validation of loaded data so that it doesn't have to be checked in each function

type ModelInfo Uses

type ModelInfo struct {
    // NOTE don't change order of these json exported properties because it will change users' model.json files
    Note1                string    `json:"_note1"`
    Note2                string    `json:"_note2"`
    Note3                string    `json:"_note3"`
    Entities             []*Entity `json:"entities"`
    LastEntityId         IdUid     `json:"lastEntityId"`
    LastIndexId          IdUid     `json:"lastIndexId"`
    LastRelationId       IdUid     `json:"lastRelationId"`
    ModelVersion         int       `json:"modelVersion"`
    MinimumParserVersion int       `json:"modelVersionParserMinimum"`
    RetiredEntityUids    []Uid     `json:"retiredEntityUids"`
    RetiredIndexUids     []Uid     `json:"retiredIndexUids"`
    RetiredPropertyUids  []Uid     `json:"retiredPropertyUids"`
    RetiredRelationUids  []Uid     `json:"retiredRelationUids"`
    Version              int       `json:"version"` // user specified version

    Rand *rand.Rand `json:"-"` // seeded random number generator

    // Model Template
    Package string `json:"-"`
    // contains filtered or unexported fields
}

ModelInfo is a serialization interface for the model JSON file

func LoadOrCreateModel Uses

func LoadOrCreateModel(path string) (model *ModelInfo, err error)

LoadOrCreateModel reads a model file or creates a new one if it doesn't exist

func (*ModelInfo) CheckRelationCycles Uses

func (model *ModelInfo) CheckRelationCycles() error

CheckRelationCycles finds relations cycles

func (*ModelInfo) Close Uses

func (model *ModelInfo) Close() error

Close and unlock model

func (*ModelInfo) CreateEntity Uses

func (model *ModelInfo) CreateEntity(name string) (*Entity, error)

CreateEntity creates an entity

func (*ModelInfo) FindEntityByName Uses

func (model *ModelInfo) FindEntityByName(name string) (*Entity, error)

FindEntityByName finds entity by name

func (*ModelInfo) FindEntityByUid Uses

func (model *ModelInfo) FindEntityByUid(uid Uid) (*Entity, error)

FindEntityByUid finds entity by Uid

func (*ModelInfo) GenerateUid Uses

func (model *ModelInfo) GenerateUid() (result Uid, err error)

GenerateUid generates a unique UID

func (*ModelInfo) Validate Uses

func (model *ModelInfo) Validate() (err error)

Validate performs initial validation of loaded data so that it doesn't have to be checked in each function

func (*ModelInfo) Write Uses

func (model *ModelInfo) Write() error

Write current model data to file

type Property Uses

type Property struct {
    Id             IdUid  `json:"id"`
    Name           string `json:"name"`
    IndexId        *IdUid `json:"indexId,omitempty"` // a pointer because it may be nil
    Type           int    `json:"type"`
    Flags          int    `json:"flags,omitempty"`
    RelationTarget string `json:"relationTarget,omitempty"`
    // contains filtered or unexported fields
}

Property in a model

func CreateProperty Uses

func CreateProperty(entity *Entity, id Id, uid Uid) *Property

CreateProperty creates a property

func (*Property) CreateIndex Uses

func (property *Property) CreateIndex() error

CreateIndex creates an index

func (*Property) RemoveIndex Uses

func (property *Property) RemoveIndex() error

RemoveIndex removes an index

func (*Property) Validate Uses

func (property *Property) Validate() error

Validate performs initial validation of loaded data so that it doesn't have to be checked in each function

type StandaloneRelation Uses

type StandaloneRelation struct {
    Id       IdUid   `json:"id"`
    Name     string  `json:"name"`
    Target   *Entity `json:"-"`
    TargetId IdUid   `json:"targetId"`
    // contains filtered or unexported fields
}

StandaloneRelation in a model

func CreateStandaloneRelation Uses

func CreateStandaloneRelation(entity *Entity, id IdUid) *StandaloneRelation

CreateStandaloneRelation creates a standalone relation

func (*StandaloneRelation) SetTarget Uses

func (relation *StandaloneRelation) SetTarget(entity *Entity)

SetTarget sets the relation target entity

func (*StandaloneRelation) Validate Uses

func (relation *StandaloneRelation) Validate() error

Validate performs initial validation of loaded data so that it doesn't have to be checked in each function

type Uid Uses

type Uid = uint64

Uid identifies an element globally (i.e. is unique across the whole model)

Package modelinfo imports 9 packages (graph) and is imported by 1 packages. Updated 2019-12-31. Refresh now. Tools for package owners.