Documentation ¶
Index ¶
- Variables
- func EntityType(entity Entity) string
- func GetFQNameByID(tx *gorm.DB, id uuid.UUID, entityType string) (string, error)
- func GetIDByFQName(tx *gorm.DB, fqname string, entityType string) (uuid.UUID, error)
- func MigrateDataModel(db *gorm.DB)
- func ModelNames() []string
- func PopulateEntity(entity Entity, payload map[string]interface{}) (err error)
- func SaveEntity(db *gorm.DB, entity Entity) error
- func UpdateEntity(db *gorm.DB, entity Entity) error
- type BaseModel
- type BaseRef
- type Device
- type DeviceDevice_family
- type Device_family
- type Domain
- type Entity
- type ModelInfo
- type Project
- type RefEntity
Constants ¶
This section is empty.
Variables ¶
var ( // EmptyUUID for empty UUID EmptyUUID uuid.UUID = uuid.UUID{} )
Functions ¶
func GetFQNameByID ¶
GetFQNameByID queries DB for ID by FQName
func GetIDByFQName ¶
GetIDByFQName queries DB for FQName by ID
func MigrateDataModel ¶
MigrateDataModel - Auto migrate project models
func PopulateEntity ¶
PopulateEntity with json payload
Types ¶
type BaseModel ¶
type BaseModel struct { ID uuid.UUID `gorm:"column:id;type:uuid;primary_key:<-create"` Name string `gorm:"column:name;size:128;not null;<-:create"` DisplayName string `gorm:"column:display_name;size:128;not null"` ParentID uuid.UUID `gorm:"column:parent_id;type:uuid;<-:create"` ParentType string `gorm:"column:parent_type;<-:create"` FQName string `gorm:"column:fqname;not null;uniqueIndex;<:create"` Payload datatypes.JSON `gorm:"column:payload"` // contains filtered or unexported fields }
BaseModel - base database entity model
type BaseRef ¶
type BaseRef struct { FromFQName string `gorm:"column:from_fqname"` ToFQName string `gorm:"column:to_fqname"` Payload datatypes.JSON `gorm:"column:payload"` }
BaseRef - base ref entity model
type Device ¶
type Device struct { Base BaseModel `gorm:"embedded" parentTypes:"domain,project"` // fields Connection_type string `gorm:"column:connction_type"` // Many-Many relations Device_families []Device_family `gorm:"many2many:device_device_families"` }
Device -----------------------------------------------------------------
func (*Device) BeforeCreate ¶
BeforeCreate to validate and set default
type DeviceDevice_family ¶
type DeviceDevice_family struct { Base BaseRef `gorm:"embedded"` DeviceID uuid.UUID Device_familyID uuid.UUID }
DeviceDevice_family -----------------------------------------------------------
func (*DeviceDevice_family) BaseRef ¶
func (entity *DeviceDevice_family) BaseRef() *BaseRef
BaseRef returns the reference to the BaseRef model
type Device_family ¶
type Device_family struct {
Base BaseModel `gorm:"embedded" parentTypes:"project"`
}
Device_family -----------------------------------------------------------------
func (*Device_family) BaseModel ¶
func (entity *Device_family) BaseModel() *BaseModel
BaseModel returns the reference to the base model
func (*Device_family) BeforeCreate ¶
func (entity *Device_family) BeforeCreate(tx *gorm.DB) error
BeforeCreate to validate and set default
type Domain ¶
type Domain struct {
Base BaseModel `gorm:"embedded"`
}
Domain -----------------------------------------------------------------
func (*Domain) BeforeCreate ¶
BeforeCreate to validate and set default
type Entity ¶
type Entity interface { BaseModel() *BaseModel Find(db *gorm.DB, conds ...interface{}) ([]Entity, error) }
Entity is base interface for all models
type ModelInfo ¶
type ModelInfo struct { ParentTypes []string ChildTypes []string RefTypes []string BackRefTypes []string NormalizedFields []string }
ModelInfo contains entity model meta info
func GetModelInfo ¶
GetModelInfo return entity model meta info
type Project ¶
type Project struct {
Base BaseModel `gorm:"embedded" parentTypes:"domain"`
}
Project -----------------------------------------------------------------
func (*Project) BeforeCreate ¶
BeforeCreate to validate and set default