Documentation ¶
Overview ¶
Package model provides a class including Id, CreatedAt and UpdatedAt, and some utility functions, optionally include in your models
Index ¶
- func CleanParams(params map[string]string, allowed []string) map[string]string
- type Model
- func (m *Model) CacheKey() string
- func (m *Model) Init()
- func (m *Model) OwnedBy(uid int64) bool
- func (m *Model) PrimaryKey() string
- func (m *Model) PrimaryKeyValue() int64
- func (m *Model) ResourceID() string
- func (m *Model) SelectName() string
- func (m *Model) SelectValue() string
- func (m *Model) String() string
- func (m *Model) Table() string
- func (m *Model) ToSlug(name string) string
- func (m *Model) URLCreate() string
- func (m *Model) URLDestroy() string
- func (m *Model) URLIndex() string
- func (m *Model) URLShow() string
- func (m *Model) URLUpdate() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Model ¶
type Model struct { // Id is the default primary key of the model Id int64 // CreatedAt stores the creation time of the model and should not be changed after cretion CreatedAt time.Time // UpdatedAt stores the last update time of the model UpdatedAt time.Time // TableName is used for database queries and urls TableName string // KeyName is used for database queries as the primary key KeyName string }
Model base class
func (*Model) CacheKey ¶
CacheKey generates a cache key for this model object, dependent on id and UpdatedAt should we generate a hash of this to ensure we fit in small key size?
func (*Model) PrimaryKey ¶
PrimaryKey returns the id for primary key by default - used by query
func (*Model) PrimaryKeyValue ¶
PrimaryKeyValue returns the unique id
func (*Model) ResourceID ¶
ResourceID returns a key unique to this resource (we use table).
func (*Model) SelectName ¶
SelectName returns our name for select menus
func (*Model) SelectValue ¶
SelectValue returns our value for select options
func (*Model) ToSlug ¶
ToSlug converts our name to something suitable for use on the web as part of a url
func (*Model) URLDestroy ¶
URLDestroy returns the destroy url for this model /table/id/destroy