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 HTTP
- type IDoRealDelete
- type IHasPermissions
- type IOwnership
- type IValidate
- type JSONIDPatch
- 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 IDoRealDelete ¶
type IDoRealDelete interface {
DoRealDelete() bool
}
IDoRealDelete is an interface to customize specification for real db delete
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 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 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