Documentation ¶
Index ¶
- Constants
- func ValidMediaTypes() []string
- type Collection
- type CollectionField
- type CollectionForm
- type Entity
- type EntityForm
- type Key
- type KeyForm
- type Language
- type LanguageForm
- type Media
- type MediaUpdateForm
- type MetaChecklist
- type MetaChecklistOption
- type MetaDate
- type MetaEditor
- type MetaFieldInterface
- type MetaMedia
- type MetaPlain
- type MetaRelation
- type MetaSelect
- type MetaSelectOption
- type MetaSwitch
- type User
- type UserCreateForm
- type UserResetPasswordForm
- type UserUpdateForm
Constants ¶
const ( // CollectionField supported type constants FieldTypePlain = "plain" FieldTypeSwitch = "switch" FieldTypeChecklist = "checklist" FieldTypeSelect = "select" FieldTypeDate = "date" FieldTypeEditor = "editor" FieldTypeMedia = "media" FieldTypeRelation = "relation" // MetaEditor supported modes MetaEditorModeSimple = "simple" MetaEditorModeRich = "rich" // MetaDate supported modes MetaDateModeDate = "date" MetaDateModeDateTime = "datetime" )
const ( // EntityStatusActive specifies the active entity model status state. EntityStatusActive = "active" // EntityStatusInactive specifies the inactive entity model status state. EntityStatusInactive = "inactive" )
const ( // UserStatusActive specifies the active user model status state. UserStatusActive = "active" // UserStatusActive specifies the inactive user model status state. UserStatusInactive = "inactive" )
Variables ¶
This section is empty.
Functions ¶
func ValidMediaTypes ¶
func ValidMediaTypes() []string
ValidMediaTypes returns array with all valid media mime-types.
Types ¶
type Collection ¶
type Collection struct { ID bson.ObjectId `json:"id" bson:"_id"` Title string `json:"title" bson:"title"` Name string `json:"name" bson:"name"` Fields []CollectionField `json:"fields" bson:"fields"` CreateHook string `json:"create_hook" bson:"create_hook"` UpdateHook string `json:"update_hook" bson:"update_hook"` DeleteHook string `json:"delete_hook" bson:"delete_hook"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
Collection defines the Collection model fields.
type CollectionField ¶
type CollectionField struct { Key string `json:"key" bson:"key" form:"key"` Type string `json:"type" bson:"type" form:"type"` Label string `json:"label" bson:"label" form:"label"` Required bool `json:"required" bson:"required" form:"required"` Unique bool `json:"unique" bson:"unique" form:"unique"` Multilingual bool `json:"multilingual" bson:"multilingual" form:"multilingual"` Default interface{} `json:"default" bson:"default" form:"default"` Meta interface{} `json:"meta" bson:"meta" form:"meta"` }
CollectionField defines single CollectionField struct properties.
func (CollectionField) CastValue ¶
func (m CollectionField) CastValue(value interface{}) interface{}
CastValue returns normalized field value.
func (CollectionField) IsEmptyValue ¶
func (m CollectionField) IsEmptyValue(value interface{}) bool
IsEmptyValue checks whether the provided field value is represents empty casted (!!!) field value.
func (CollectionField) Validate ¶
func (m CollectionField) Validate() error
Validate validates the CollectionField struct properties.
type CollectionForm ¶
type CollectionForm struct { Model *Collection `json:"-" form:"-"` Title string `json:"title" form:"title"` Name string `json:"name" form:"name"` Fields []CollectionField `json:"fields" form:"fields"` CreateHook string `json:"create_hook" form:"create_hook"` UpdateHook string `json:"update_hook" form:"update_hook"` DeleteHook string `json:"delete_hook" form:"delete_hook"` }
CollectionForm defines the Collection update/create form model.
func (CollectionForm) ResolveModel ¶
func (m CollectionForm) ResolveModel() *Collection
ResolveModel resolves and returns the form Collection model. If the form doesn't have a Collection model, it will instantiate a new one.
func (CollectionForm) Validate ¶
func (m CollectionForm) Validate() error
Validate validates the CollectionForm struct properties.
type Entity ¶
type Entity struct { ID bson.ObjectId `json:"id" bson:"_id"` CollectionID bson.ObjectId `json:"collection_id" bson:"collection_id"` Status string `json:"status" bson:"status"` Data map[string]map[string]interface{} `json:"data" bson:"data"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
Entity defines the Entity model fields.
type EntityForm ¶
type EntityForm struct { Model *Entity `json:"-" form:"-"` CollectionID bson.ObjectId `json:"collection_id" form:"collection_id"` Status string `json:"status" form:"status"` Data map[string]map[string]interface{} `json:"data" form:"data"` }
EntityForm defines the update/create form model fields.
func (EntityForm) ResolveModel ¶
func (m EntityForm) ResolveModel() *Entity
ResolveModel resolves and returns the form Entity model. If the form doesn't have an Entity model, it will instantiate a new one.
func (EntityForm) Validate ¶
func (m EntityForm) Validate() error
Validate validates the EntityForm struct fields.
type Key ¶
type Key struct { ID bson.ObjectId `json:"id" bson:"_id"` Title string `json:"title" bson:"title"` Token string `json:"token" bson:"token"` Access map[string][]string `json:"access" bson:"access"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
Key defines the API Key model fields.
type KeyForm ¶
type KeyForm struct { Model *Key `json:"-" form:"-"` Title string `json:"title" form:"title"` Access map[string][]string `json:"access" form:"access"` }
KeyForm defines the update/create form model fields.
func (KeyForm) ResolveModel ¶
ResolveModel resolves and returns the form Key model. If the form doesn't have a Key model, it will instantiate a new one.
type Language ¶
type Language struct { ID bson.ObjectId `json:"id" bson:"_id"` Locale string `json:"locale" bson:"locale"` Title string `json:"title" bson:"title"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
Language defines the Language model fields.
type LanguageForm ¶
type LanguageForm struct { Model *Language `json:"-" form:"-"` Title string `json:"title" form:"title"` Locale string `json:"locale" form:"locale"` }
LanguageForm defines the update/create form model fields.
func (LanguageForm) ResolveModel ¶
func (m LanguageForm) ResolveModel() *Language
ResolveModel resolves and returns the form Language model. If the form doesn't have a Language model, it will instantiate a new one.
func (LanguageForm) Validate ¶
func (m LanguageForm) Validate() error
Validate validates the LanguageForm struct fields.
type Media ¶
type Media struct { ID bson.ObjectId `json:"id" bson:"_id"` Type string `json:"type" bson:"type"` Title string `json:"title" bson:"title"` Description string `json:"description" bson:"description"` Path string `json:"path" bson:"path"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
Media defines the Media model fields.
func (*Media) DeleteFile ¶
DeleteFile deletes the file (and its thumbs if image) associated to the Media item from the file system.
type MediaUpdateForm ¶
type MediaUpdateForm struct { Model *Media `json:"-" form:"-"` Title string `json:"title" form:"title"` Description string `json:"description" form:"description"` }
MediaUpdateForm defines the media update form fields.
func (MediaUpdateForm) ResolveModel ¶
func (m MediaUpdateForm) ResolveModel() *Media
ResolveModel resolves and returns the form Media model.
func (MediaUpdateForm) Validate ¶
func (m MediaUpdateForm) Validate() error
Validate validates media update form fields.
type MetaChecklist ¶
type MetaChecklist struct {
Options []MetaChecklistOption `json:"options" bson:"options" form:"options"`
}
MetaChecklist struct for the checklist field meta data model
func NewMetaChecklist ¶
func NewMetaChecklist(data interface{}) (*MetaChecklist, error)
NewMetaChecklist creates and returns new MetaChecklist instance.
func (MetaChecklist) Validate ¶
func (m MetaChecklist) Validate() error
Validate validates the checklist collection field meta properties.
type MetaChecklistOption ¶
type MetaChecklistOption struct { Name string `json:"name" bson:"name" form:"name"` Value string `json:"value" bson:"value" form:"value"` }
MetaChecklistOption struct describing single checklist meta option field model
func (MetaChecklistOption) Validate ¶
func (m MetaChecklistOption) Validate() error
Validate validates the checklist collection field meta options properties.
type MetaDate ¶
type MetaDate struct {
Mode string `json:"mode" bson:"mode" form:"mode"`
}
MetaDate struct for the date field meta data model
func NewMetaDate ¶
NewMetaDate creates and returns new MetaDate instance.
type MetaEditor ¶
type MetaEditor struct {
Mode string `json:"mode" bson:"mode" form:"mode"`
}
MetaEditor struct for the editor field meta data model
func NewMetaEditor ¶
func NewMetaEditor(data interface{}) (*MetaEditor, error)
NewMetaEditor creates and returns new MetaEditor instance.
func (MetaEditor) Validate ¶
func (m MetaEditor) Validate() error
Validate validates the editor collection field meta properties.
type MetaFieldInterface ¶
type MetaFieldInterface interface {
Validate() error
}
MetaFieldInterface interfaces that defines common methods and structure of a meta field.
type MetaMedia ¶
type MetaMedia struct {
Max uint8 `json:"max" bson:"max" form:"max"`
}
MetaMedia struct for the media field meta data model
func NewMetaMedia ¶
NewMetaMedia creates and returns new MetaMedia instance.
type MetaPlain ¶
type MetaPlain struct { }
MetaPlain struct for the plain field meta data model
func NewMetaPlain ¶
NewMetaPlain creates and returns new MetaPlain instance.
type MetaRelation ¶
type MetaRelation struct { Max uint8 `json:"max" bson:"max" form:"max"` CollectionID bson.ObjectId `json:"collection_id" bson:"collection_id" form:"collection_id"` }
MetaRelation struct for the relation field meta data model
func NewMetaRelation ¶
func NewMetaRelation(data interface{}) (*MetaRelation, error)
NewMetaRelation creates and returns new MetaRelation instance.
func (MetaRelation) Validate ¶
func (m MetaRelation) Validate() error
Validate validates the relation collection field meta properties.
type MetaSelect ¶
type MetaSelect struct {
Options []MetaSelectOption `json:"options" bson:"options" form:"options"`
}
MetaSelect struct for the select field meta data model
func NewMetaSelect ¶
func NewMetaSelect(data interface{}) (*MetaSelect, error)
NewMetaSelect creates and returns new MetaSelect instance.
func (MetaSelect) Validate ¶
func (m MetaSelect) Validate() error
Validate validates the select collection field meta properties.
type MetaSelectOption ¶
type MetaSelectOption struct { Name string `json:"name" bson:"name" form:"name"` Value string `json:"value" bson:"value" form:"value"` }
MetaSelectOption struct describing single select meta option field model
func (MetaSelectOption) Validate ¶
func (m MetaSelectOption) Validate() error
Validate validates the select collection field meta options properties.
type MetaSwitch ¶
type MetaSwitch struct { }
MetaSwitch struct for the switch field meta data model
func NewMetaSwitch ¶
func NewMetaSwitch(data interface{}) (*MetaSwitch, error)
NewMetaSwitch creates and returns new MetaSwitch instance.
func (MetaSwitch) Validate ¶
func (m MetaSwitch) Validate() error
type User ¶
type User struct { ID bson.ObjectId `json:"id" bson:"_id"` Username string `json:"username" bson:"username"` Email string `json:"email" bson:"email"` Status string `json:"status" bson:"status"` PasswordHash string `json:"-" bson:"password_hash"` ResetPasswordHash string `json:"-" bson:"reset_password_hash"` Access map[string][]string `json:"access" bson:"access"` Created int64 `json:"created" bson:"created"` Modified int64 `json:"modified" bson:"modified"` }
User defines the User model fields.
func (User) HasValidResetPasswordHash ¶
HasValidResetPasswordHash checks whether the model reset password hash is valid.
func (User) NewAuthToken ¶
NewAuthToken generates and returns new user authentication token.
func (*User) SetPassword ¶
SetPassword sets cryptographically secure User model `PasswordHash` string
func (*User) SetResetPasswordHash ¶
SetResetPasswordHash sets new user reset password hash.
func (User) ValidatePassword ¶
ValidatePassword validates User model `PasswordHash` string against a plain password
type UserCreateForm ¶
type UserCreateForm struct { Username string `json:"username" form:"username"` Email string `json:"email" form:"email"` Status string `json:"status" form:"status"` Password string `json:"password" form:"password"` PasswordConfirm string `json:"password_confirm" form:"password_confirm"` Access map[string][]string `json:"access" form:"access"` }
UserCreateForm defines struct to create a new user.
func (UserCreateForm) ResolveModel ¶
func (m UserCreateForm) ResolveModel() *User
ResolveModel creates and returns new User model based on the create form fields.
func (UserCreateForm) Validate ¶
func (m UserCreateForm) Validate() error
Validate validates user create form fields.
type UserResetPasswordForm ¶
type UserResetPasswordForm struct { Model *User `json:"-" form:"-"` Password string `json:"password" form:"password"` PasswordConfirm string `json:"password_confirm" form:"password_confirm"` }
UserUpdateForm defines struct to update an user.
func (UserResetPasswordForm) ResolveModel ¶
func (m UserResetPasswordForm) ResolveModel() *User
ResolveModel resolves and returns the reset password form user model.
func (UserResetPasswordForm) Validate ¶
func (m UserResetPasswordForm) Validate() error
Validate validates user reset password form fields.
type UserUpdateForm ¶
type UserUpdateForm struct { Model *User `json:"-" form:"-"` Username string `json:"username" form:"username"` Email string `json:"email" form:"email"` Status string `json:"status" form:"status"` Access map[string][]string `json:"access" form:"access"` Password string `json:"password" form:"password"` PasswordConfirm string `json:"password_confirm" form:"password_confirm"` }
UserUpdateForm defines struct to update an user.
func (UserUpdateForm) ResolveModel ¶
func (m UserUpdateForm) ResolveModel() *User
ResolveModel resolves and returns the update form user model.
func (UserUpdateForm) Validate ¶
func (m UserUpdateForm) Validate() error
Validate validates user update form fields.