Documentation ¶
Index ¶
- type AbstractAccessor
- func (dma *AbstractAccessor) GetCaller() *tools.HTTPCaller
- func (dma *AbstractAccessor) GetGroups() []string
- func (dma *AbstractAccessor) GetLogger() *zerolog.Logger
- func (dma *AbstractAccessor) GetPeerID() string
- func (r *AbstractAccessor) GetRequest() *tools.APIRequest
- func (dma *AbstractAccessor) GetType() tools.DataType
- func (dma *AbstractAccessor) GetUser() string
- type AbstractObject
- func (r *AbstractObject) CanDelete() bool
- func (r *AbstractObject) CanUpdate(set DBObject) (bool, DBObject)
- func (dma *AbstractObject) Deserialize(j map[string]interface{}, obj DBObject) DBObject
- func (r *AbstractObject) GenerateID()
- func (ao *AbstractObject) GetCreatorID() string
- func (ao AbstractObject) GetID() string
- func (ao AbstractObject) GetName() string
- func (ao *AbstractObject) GetObjectFilters(search string) *dbs.Filters
- func (r *AbstractObject) IsDrafted() bool
- func (dma *AbstractObject) Serialize(obj DBObject) map[string]interface{}
- func (r *AbstractObject) StoreDraftDefault()
- func (ao *AbstractObject) UpToDate(user string, create bool)
- func (ao *AbstractObject) VerifyAuth(request *tools.APIRequest) bool
- type AccessMode
- type Accessor
- type DBObject
- func GenericDeleteOne(id string, a Accessor) (DBObject, int, error)
- func GenericLoadOne[T DBObject](id string, f func(DBObject) (DBObject, int, error), a Accessor) (DBObject, int, error)
- func GenericRawUpdateOne(set DBObject, id string, a Accessor) (DBObject, int, error)
- func GenericStoreOne(data DBObject, a Accessor) (DBObject, int, error)
- func GenericUpdateOne(set DBObject, id string, a Accessor, new DBObject) (DBObject, int, error)
- type Owner
- type ShallowDBObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractAccessor ¶
type AbstractAccessor struct { Logger zerolog.Logger // Logger is the logger of the accessor, it's a specilized logger for the accessor Type tools.DataType // Type is the data type of the accessor Request *tools.APIRequest // Caller is the http caller of the accessor (optionnal) only need in a peer connection ResourceModelAccessor Accessor }
func (*AbstractAccessor) GetCaller ¶
func (dma *AbstractAccessor) GetCaller() *tools.HTTPCaller
func (*AbstractAccessor) GetGroups ¶
func (dma *AbstractAccessor) GetGroups() []string
func (*AbstractAccessor) GetLogger ¶
func (dma *AbstractAccessor) GetLogger() *zerolog.Logger
func (*AbstractAccessor) GetPeerID ¶
func (dma *AbstractAccessor) GetPeerID() string
func (*AbstractAccessor) GetRequest ¶
func (r *AbstractAccessor) GetRequest() *tools.APIRequest
func (*AbstractAccessor) GetType ¶
func (dma *AbstractAccessor) GetType() tools.DataType
func (*AbstractAccessor) GetUser ¶
func (dma *AbstractAccessor) GetUser() string
type AbstractObject ¶
type AbstractObject struct { UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"` Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"` IsDraft bool `json:"is_draft" bson:"is_draft" default:"false"` CreatorID string `json:"creator_id" bson:"creator_id" default:"unknown"` CreationDate time.Time `json:"creation_date" bson:"creation_date"` UpdateDate time.Time `json:"update_date" bson:"update_date"` UpdaterID string `json:"updater_id" bson:"updater_id"` AccessMode AccessMode `json:"access_mode" bson:"access_mode" default:"0"` }
* AbstractObject is a struct that represents the basic fields of an object * it defines the object id and name * every data in base root model should inherit from this struct (only exception is the ResourceModel)
func (*AbstractObject) CanDelete ¶
func (r *AbstractObject) CanDelete() bool
func (*AbstractObject) CanUpdate ¶
func (r *AbstractObject) CanUpdate(set DBObject) (bool, DBObject)
func (*AbstractObject) Deserialize ¶
func (dma *AbstractObject) Deserialize(j map[string]interface{}, obj DBObject) DBObject
func (*AbstractObject) GenerateID ¶
func (r *AbstractObject) GenerateID()
func (*AbstractObject) GetCreatorID ¶
func (ao *AbstractObject) GetCreatorID() string
func (AbstractObject) GetID ¶
func (ao AbstractObject) GetID() string
GetID implements ShallowDBObject.
func (AbstractObject) GetName ¶
func (ao AbstractObject) GetName() string
GetName implements ShallowDBObject.
func (*AbstractObject) GetObjectFilters ¶
func (ao *AbstractObject) GetObjectFilters(search string) *dbs.Filters
func (*AbstractObject) IsDrafted ¶
func (r *AbstractObject) IsDrafted() bool
func (*AbstractObject) Serialize ¶
func (dma *AbstractObject) Serialize(obj DBObject) map[string]interface{}
func (*AbstractObject) StoreDraftDefault ¶
func (r *AbstractObject) StoreDraftDefault()
func (*AbstractObject) UpToDate ¶
func (ao *AbstractObject) UpToDate(user string, create bool)
func (*AbstractObject) VerifyAuth ¶
func (ao *AbstractObject) VerifyAuth(request *tools.APIRequest) bool
type Accessor ¶
type Accessor interface { GetRequest() *tools.APIRequest GetType() tools.DataType GetUser() string GetPeerID() string GetGroups() []string GetLogger() *zerolog.Logger GetCaller() *tools.HTTPCaller Search(filters *dbs.Filters, search string, isDraft bool) ([]ShallowDBObject, int, error) LoadAll(isDraft bool) ([]ShallowDBObject, int, error) LoadOne(id string) (DBObject, int, error) DeleteOne(id string) (DBObject, int, error) CopyOne(data DBObject) (DBObject, int, error) StoreOne(data DBObject) (DBObject, int, error) UpdateOne(set DBObject, id string) (DBObject, int, error) }
Accessor is an interface that defines the basic methods for an Accessor
type DBObject ¶
type DBObject interface { GenerateID() GetID() string GetName() string GetCreatorID() string IsDrafted() bool StoreDraftDefault() CanUpdate(set DBObject) (bool, DBObject) CanDelete() bool UpToDate(user string, create bool) VerifyAuth(request *tools.APIRequest) bool Deserialize(j map[string]interface{}, obj DBObject) DBObject Serialize(obj DBObject) map[string]interface{} GetAccessor(request *tools.APIRequest) Accessor }
DBObject is an interface that defines the basic methods for a DBObject
func GenericDeleteOne ¶
GenericLoadOne loads one object from the database (generic)
func GenericLoadOne ¶
func GenericRawUpdateOne ¶
GenericLoadOne loads one object from the database (generic) json expected in entry is a flatted object no need to respect the inheritance hierarchy
func GenericStoreOne ¶
GenericLoadOne loads one object from the database (generic)
type ShallowDBObject ¶
type ShallowDBObject interface { GenerateID() GetID() string GetName() string Deserialize(j map[string]interface{}, obj DBObject) DBObject Serialize(obj DBObject) map[string]interface{} }
ShallowDBObject is an interface that defines the basic methods shallowed version of a DBObject
func GenericLoadAll ¶
func GenericLoadAll[T DBObject](f func(DBObject) ShallowDBObject, onlyDraft bool, wfa Accessor) ([]ShallowDBObject, int, error)