Documentation ¶
Index ¶
- func GetFieldNameFromModelByTagKey(modelObj interface{}, valueKey string) *string
- func GetFieldTypeFromModelByTagKeyBetterRestAndValueKey(modelObj mdl.IModel, valueKey string, recurseIntoEmbedded bool) reflect.Type
- func GetFieldValueFromModelByTagKeyBetterRestAndValueKey(modelObj mdl.IModel, valueKey string) interface{}
- func GetTagValueFromModelByTagKeyBetterRestAndValueKey(modelObj interface{}, valueKey string) *string
- type BatchHookCargo
- type BatchHookPointData
- type CRUPDOp
- type HTTP
- type HookPointData
- type IAfterCRUPD
- type IAfterCreate
- type IAfterDelete
- type IAfterPatch
- type IAfterRead
- type IAfterTransact
- type IAfterUpdate
- type IBeforeCUPD
- type IBeforeCreate
- type IBeforeDelete
- type IBeforePatch
- type IBeforePatchApply
- type IBeforeUpdate
- type IDoRealDelete
- type IGuardAPIEntry
- type IHasPermissions
- type IHasRenderer
- type IOwnership
- type IValidate
- type JSONIDPatch
- type ModelCargo
- type OwnershipModelBase
- type OwnershipModelWithIDBase
- func (b *OwnershipModelWithIDBase) GetCreatedAt() *time.Time
- func (o *OwnershipModelWithIDBase) GetID() *datatype.UUID
- func (o *OwnershipModelWithIDBase) GetModelID() *datatype.UUID
- func (b *OwnershipModelWithIDBase) GetUpdatedAt() *time.Time
- func (o *OwnershipModelWithIDBase) GetUserID() *datatype.UUID
- func (o *OwnershipModelWithIDBase) SetID(id *datatype.UUID)
- func (o *OwnershipModelWithIDBase) SetModelID(id *datatype.UUID)
- func (o *OwnershipModelWithIDBase) SetUserID(id *datatype.UUID)
- type UserIDFetchable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFieldNameFromModelByTagKey ¶
GetFieldNameFromModelByTagKey get's the name of the tagged field If it's a slice, it returns the element type It's an interface{} because it's not necessarily IModel
func GetFieldTypeFromModelByTagKeyBetterRestAndValueKey ¶
func GetFieldTypeFromModelByTagKeyBetterRestAndValueKey(modelObj mdl.IModel, valueKey string, recurseIntoEmbedded bool) reflect.Type
GetFieldTypeFromModelByTagKeyBetterRestAndValueKey fetches the datatype of the variable tagged in tag
func GetFieldValueFromModelByTagKeyBetterRestAndValueKey ¶
func GetFieldValueFromModelByTagKeyBetterRestAndValueKey(modelObj mdl.IModel, valueKey string) interface{}
GetFieldValueFromModelByTagKeyBetterRestAndValueKey fetches value of the variable tagged in tag
Types ¶
type BatchHookCargo ¶
type BatchHookCargo struct {
Payload interface{}
}
BatchHookCargo is payload between batch update and batch delete hookpoints
type BatchHookPointData ¶
type BatchHookPointData struct { // Ms is the slice of IModels Ms []mdl.IModel // DB is the DB handle DB *gorm.DB // Who is operating this CRUPD right now Who UserIDFetchable // TypeString TypeString string // Cargo between Before and After hookpoints (not used in AfterRead since there is before read hookpoint.) Cargo *BatchHookCargo // Role of this user in relation to this data, only available during read Roles []userrole.UserRole // URL parameters URLParams map[urlparam.Param]interface{} }
BatchHookPointData is the data send to batch model hookpoints (deprecated)
type CRUPDOp ¶
type CRUPDOp int
------------------------------------------------------------------------------------ Old Rest Op CRUPDOp designates the type of operations for BeforeCRUPD and AfterCRUPD hookpoints
func HTTPMethodToCRUDOp ¶
type HookPointData ¶
type HookPointData struct { // DB handle (not available for AfterTransact) DB *gorm.DB // Who is the user information, who is operating this CRUPD right now Who UserIDFetchable // TypeString is the typeString (model string) of this model TypeString string // Cargo between Before and After hookpoints (not used in IAfterRead since there is no IBeforeRead.) // Currently not supported in the AfterTransact hookpoint Cargo *ModelCargo // Role of this user in relation to this data, only available during read Role *userrole.UserRole // URL parameters URLParams map[urlparam.Param]interface{} }
HookPointData is the data send to single model hookpoints (deprecated)
type IAfterCRUPD ¶
type IAfterCRUPD interface {
AfterCRUPDDB(hpdata HookPointData, op CRUPDOp) error
}
IAfterCRUPD supprots method to be called after data is after all CRUPD operations This is called before the individual ops
type IAfterCreate ¶
type IAfterCreate interface {
AfterCreateDB(hpdata HookPointData) error
}
IAfterCreate supports method to be called after data is inserted (created) into the database
type IAfterDelete ¶
type IAfterDelete interface {
AfterDeleteDB(hpdata HookPointData) error
}
IAfterDelete supports method to be called after data is deleted from the database
type IAfterPatch ¶
type IAfterPatch interface {
AfterPatchDB(hpdata HookPointData) error
}
IAfterPatch supports method to be called before data is patched in the database
type IAfterRead ¶
type IAfterRead interface {
AfterReadDB(hpdata HookPointData) error
}
IAfterRead supports method to be called after data is read from the database
type IAfterTransact ¶
type IAfterTransact interface {
AfterTransact(hpdata HookPointData, op CRUPDOp)
}
IAfterTransact is the method to be called after data is after the entire CRUPD transaction is done.
type IAfterUpdate ¶
type IAfterUpdate interface {
AfterUpdateDB(hpdata HookPointData) error
}
IAfterUpdate supports method to be called after data is updated in the database
type IBeforeCUPD ¶
type IBeforeCUPD interface {
BeforeCUPDDB(hpdata HookPointData, op CRUPDOp) error
}
IBeforeCUPD supprots method to be called before data is after all CRUPD operations This is called before the individual ops
type IBeforeCreate ¶
type IBeforeCreate interface {
BeforeCreateDB(hpdata HookPointData) error
}
IBeforeCreate supports method to be called before data is inserted (created) into the database
type IBeforeDelete ¶
type IBeforeDelete interface {
BeforeDeleteDB(hpdata HookPointData) error
}
IBeforeDelete supports method to be called before data is deleted from the database
type IBeforePatch ¶
type IBeforePatch interface {
BeforePatchDB(hpdata HookPointData) error
}
IBeforePatch supports method to be called before data is patched in the database
type IBeforePatchApply ¶
type IBeforePatchApply interface {
BeforePatchApplyDB(hpdata HookPointData) error
}
IBeforePatchApply supports method to be called before data is patched in the database And also before the patch is applied. This comes before BeforePatchDB
type IBeforeUpdate ¶
type IBeforeUpdate interface {
BeforeUpdateDB(hpdata HookPointData) error
}
IBeforeUpdate supports method to be called before data is updated in the database
type IDoRealDelete ¶
type IDoRealDelete interface {
DoRealDelete() bool
}
IDoRealDelete is an interface to customize specification for real db delete
type IGuardAPIEntry ¶
type IGuardAPIEntry interface {
GuardAPIEntry(who UserIDFetchable, http HTTP) bool
}
IGuardAPIEntry supports method which guard access to API based on scope
type IHasPermissions ¶
type IHasPermissions interface {
Permissions(role userrole.UserRole, who UserIDFetchable) (jsontrans.Permission, jsontrans.JSONFields)
}
IHasPermissions is for IModel with a custom permission field to cherry pick json fields default is to return all but the dates
type IHasRenderer ¶
type IHasRenderer interface {
Render(c *gin.Context, hpdata *HookPointData, op CRUPDOp) bool
}
IHasRenderer is for formatting IModel with a custom function basically do your own custom output If return false, use the default JSON output For batch renderer, register a Render(r UserRole, who modelutil.UserIDFetchable, modelObjs []IModel) bool
type IOwnership ¶
type IOwnership interface { GetRole() userrole.UserRole SetRole(userrole.UserRole) GetUserID() *datatype.UUID SetUserID(*datatype.UUID) GetModelID() *datatype.UUID SetModelID(*datatype.UUID) GetID() *datatype.UUID SetID(*datatype.UUID) }
IOwnership is what OwnershipModelBase tables should satisfy. Except OwnershipType, that's for struct which embed OwnershipModelBase
type IValidate ¶
type IValidate interface {
Validate(who UserIDFetchable, http HTTP) error
}
IValidate supports validation with govalidator
type JSONIDPatch ¶
type JSONIDPatch struct { ID *datatype.UUID `json:"id"` Patch json.RawMessage `json:"patch"` // json.RawMessage is actually just typedefed to []byte }
JSONIDPatch is the stuff inside "content" for PatchMany operation
type ModelCargo ¶
type ModelCargo struct {
Payload interface{}
}
ModelCargo is payload between hookpoints
type OwnershipModelBase ¶
type OwnershipModelBase struct { ID *datatype.UUID `gorm:"type:uuid;primary_key;" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `sql:"index" json:"deletedAt"` Role userrole.UserRole `json:"role"` // an int }
OwnershipModelBase has a role. Intended to be embedded by table serving as link from resource to user
func (*OwnershipModelBase) BeforeCreate ¶
func (o *OwnershipModelBase) BeforeCreate(scope *gorm.Scope) error
BeforeCreate sets a UUID if no ID is set (this is Gorm's hookpoint)
func (*OwnershipModelBase) GetID ¶
func (o *OwnershipModelBase) GetID() *datatype.UUID
GetID Get the ID field of the model (useful when using interface)
func (*OwnershipModelBase) GetRole ¶
func (o *OwnershipModelBase) GetRole() userrole.UserRole
GetRole gets the role field of the model, comforms to IOwnership
func (*OwnershipModelBase) SetID ¶
func (o *OwnershipModelBase) SetID(id *datatype.UUID)
SetID Set the ID field of the model (useful when using interface)
func (*OwnershipModelBase) SetRole ¶
func (o *OwnershipModelBase) SetRole(r userrole.UserRole)
SetRole sets the role field of the model, comforms to IOwnership
type OwnershipModelWithIDBase ¶
type OwnershipModelWithIDBase struct { OwnershipModelBase UserID *datatype.UUID `gorm:"index" json:"userID"` // I guess the user's table has to be named "User" then. ModelID *datatype.UUID `gorm:"index" json:"modelID"` }
OwnershipModelWithIDBase is one with ID, if you don't need unique index for userID and modelID (if you don't expose the link table via LinkTableMapper) You can use this.
func (*OwnershipModelWithIDBase) GetCreatedAt ¶
func (b *OwnershipModelWithIDBase) GetCreatedAt() *time.Time
GetCreatedAt gets the time stamp the record is created
func (*OwnershipModelWithIDBase) GetID ¶
func (o *OwnershipModelWithIDBase) GetID() *datatype.UUID
GetID Get the ID field of the model (useful when using interface)
func (*OwnershipModelWithIDBase) GetModelID ¶
func (o *OwnershipModelWithIDBase) GetModelID() *datatype.UUID
GetModelID gets the id of the model, comforms to IOwnership
func (*OwnershipModelWithIDBase) GetUpdatedAt ¶
func (b *OwnershipModelWithIDBase) GetUpdatedAt() *time.Time
GetUpdatedAt gets the time stamp the record is updated
func (*OwnershipModelWithIDBase) GetUserID ¶
func (o *OwnershipModelWithIDBase) GetUserID() *datatype.UUID
GetUserID gets the user id of the model, comforms to IOwnership
func (*OwnershipModelWithIDBase) SetID ¶
func (o *OwnershipModelWithIDBase) SetID(id *datatype.UUID)
SetID Set the ID field of the model (useful when using interface)
func (*OwnershipModelWithIDBase) SetModelID ¶
func (o *OwnershipModelWithIDBase) SetModelID(id *datatype.UUID)
SetModelID sets the id of the model, comforms to IOwnership
func (*OwnershipModelWithIDBase) SetUserID ¶
func (o *OwnershipModelWithIDBase) SetUserID(id *datatype.UUID)
SetUserID sets the user id of the model, comforms to IOwnership