Documentation ¶
Overview ¶
This entities package covers basic model and database functionnality. * Entities should generally not be directly created/retrieved/etc. except for testing purposes. Attempting to do so will result in an error. * Notice that the methods use the interface 'orm.DB', which accepts either a pg.DB or pg.Tx. This will typically be a Tx (as entity-row changes should be coordinated with other row changes in a transaction).
Index ¶
- Variables
- func RunRetrieveOp(q *orm.Query, op *retrieveOp) (int, error)
- func RunStateQueries(qs []*orm.Query, op *stateOp) error
- type EID
- type Entity
- func (e *Entity) ArchiveQueries(db orm.DB) []*orm.Query
- func (e *Entity) Clone() *Entity
- func (e *Entity) CloneNew() *Entity
- func (e *Entity) CreateQueries(db orm.DB) []*orm.Query
- func (e *Entity) DeleteQueries(db orm.DB) []*orm.Query
- func (e *Entity) GetCreatedAt() time.Time
- func (e *Entity) GetDeletedAt() time.Time
- func (e *Entity) GetDescription() string
- func (e *Entity) GetEntity() *Entity
- func (e *Entity) GetID() EID
- func (e *Entity) GetLastUpdated() time.Time
- func (e *Entity) GetName() string
- func (e *Entity) GetOwnerID() EID
- func (e *Entity) GetResourceName() ResourceName
- func (e *Entity) IsConcrete() bool
- func (e *Entity) IsPubliclyReadable() bool
- func (e *Entity) RetrieveByIDQueries(id EID, db orm.DB) *orm.Query
- func (e *Entity) SetDescription(d string)
- func (e *Entity) SetName(n string)
- func (e *Entity) SetOwnerID(pid EID)
- func (e *Entity) SetPubliclyReadable(r bool)
- func (e *Entity) UpdateQueries(db orm.DB) []*orm.Query
- type ItemManager
- func (im *ItemManager) ArchiveRaw(item archivable) error
- func (im *ItemManager) Begin() (*pg.Tx, error)
- func (im *ItemManager) BeginIfNecessary() (*pg.Tx, error)
- func (im *ItemManager) Commit() error
- func (im *ItemManager) CreateRaw(item creatable) error
- func (im *ItemManager) DeleteRaw(item deletable) error
- func (im *ItemManager) GetDB() orm.DB
- func (im *ItemManager) Rollback() error
- func (im *ItemManager) UpdateRaw(item updatable) error
- type ResourceName
Constants ¶
This section is empty.
Variables ¶
var ArchiveOp = &stateOp{ func(q *orm.Query) (orm.Result, error) { return q.Delete() }, `archive`, }
var CreateOp = &stateOp{ func(q *orm.Query) (orm.Result, error) { return q.Insert() }, `create`, }
var DeleteOp = &stateOp{ func(q *orm.Query) (orm.Result, error) { return q.ForceDelete() }, `delete`, }
var EntityFields = []string{
`resource_name`,
`name`,
`description`,
`owner_id`,
`publicly_readable`,
`created_at`,
`last_updated`,
`deleted_at`,
}
var ListOp = &retrieveOp{ func(q *orm.Query) (int, error) { return q.SelectAndCount() }, `list`, }
var MustRetrieveOp = &retrieveOp{ func(q *orm.Query) (int, error) { if err := q.Select(); err != nil { if err == pg.ErrNoRows { return 0, err } else { return -1, err } } return 1, nil }, `must retrieve`, }
Functions ¶
func RunStateQueries ¶
Types ¶
type Entity ¶
type Entity struct { // Note, the ID is for internal use only and may or may not be set depending // in the source of the item (client or backend). ID EID `json:"id" pg:",pk"` ResourceName ResourceName `json:"resourceName"` Name string `json:"name"` Description string `json:"description"` OwnerID EID `json:"ownerPubId"` PubliclyReadable bool `json:"publiclyReadable" pg:",notnull"` CreatedAt time.Time `json:"createdAt"` LastUpdated time.Time `json:"lastUpdated"` DeletedAt time.Time `json:"deletedAt" pg:",soft_delete"` // contains filtered or unexported fields }
Entity is the base type for all independent entities in the Liquid Code model. Any item which is directly retrievable, an authorization target, or authorization subject must embed the Entity type. An Entity should be considered an "abstract" type and never created directly, but only as part of a concrete, final type.
func (*Entity) GetCreatedAt ¶
func (*Entity) GetDeletedAt ¶
func (*Entity) GetDescription ¶
func (*Entity) GetLastUpdated ¶
func (*Entity) GetOwnerID ¶
func (*Entity) GetResourceName ¶
func (e *Entity) GetResourceName() ResourceName
func (*Entity) IsConcrete ¶
func (*Entity) IsPubliclyReadable ¶
func (*Entity) RetrieveByIDQueries ¶
func (*Entity) SetDescription ¶
func (*Entity) SetOwnerID ¶
func (*Entity) SetPubliclyReadable ¶
type ItemManager ¶
type ItemManager struct { AllowUnsafeStateChange bool // contains filtered or unexported fields }
func ConnectItemManager ¶
func ConnectItemManager() *ItemManager
func ConnectItemManagerWithContext ¶
func ConnectItemManagerWithContext(ctx context.Context) *ItemManager
func (*ItemManager) ArchiveRaw ¶
func (im *ItemManager) ArchiveRaw(item archivable) error
func (*ItemManager) BeginIfNecessary ¶
func (im *ItemManager) BeginIfNecessary() (*pg.Tx, error)
func (*ItemManager) Commit ¶
func (im *ItemManager) Commit() error
func (*ItemManager) CreateRaw ¶
func (im *ItemManager) CreateRaw(item creatable) error
func (*ItemManager) DeleteRaw ¶
func (im *ItemManager) DeleteRaw(item deletable) error
func (*ItemManager) GetDB ¶
func (im *ItemManager) GetDB() orm.DB
func (*ItemManager) Rollback ¶
func (im *ItemManager) Rollback() error
func (*ItemManager) UpdateRaw ¶
func (im *ItemManager) UpdateRaw(item updatable) error
type ResourceName ¶
type ResourceName string