Documentation
¶
Index ¶
- func AddArticle(article *Article) bool
- func AddOption(option *Option) (bool, error)
- func ArticleExist(id uint64) bool
- func ArticlesCount() int
- func DeleteOptionByName(optionName string) (bool, error)
- func InitTables()
- func OptionExist(optionName string) (bool, error)
- func UpdateOptionByName(option Option) (bool, error)
- type Article
- type Option
- type User
- type WebAuthnCredential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOption ¶ added in v0.0.2
AddOption adds option to DB `option` table, return boolean value. If result returned is `true`, insert option data to DB successful.
func DeleteOptionByName ¶
DeleteOptionByName deletes an Option by 'option_name'. If result returned is `true`, delete option data successful.
func InitTables ¶ added in v0.0.1
func InitTables()
func OptionExist ¶
OptionExist if the option_name of option exist If `true`, this option already exists.
func UpdateOptionByName ¶
UpdateOptionByName updates an option by 'option_name'. If result returned is `true`, update option data successful.
Types ¶
type Article ¶
type Article struct {
ID uint64 `json:"ID" xorm:"bigint(20) notnull autoincr pk 'ID'"`
Slug string `json:"slug,omitempty" xorm:"varchar(255) unique notnull 'slug'"`
Title string `json:"title" xorm:"text notnull 'title'"`
Content string `json:"content" xorm:"longtext notnull 'content'"`
Views uint64 `json:"article_views" xorm:"bigint(20) notnull default(0) 'article_views'"`
Status int `json:"article_status,omitempty" xorm:"tinyint(4) notnull default(0) 'article_status'"`
CreateTime *time.Time `json:"create_time,omitempty" xorm:"datetime created notnull 'create_time'"`
UpdateTime *time.Time `json:"update_time,omitempty" xorm:"datetime updated notnull 'update_time'"`
DeleteTime *time.Time `json:"delete_time,omitempty" xorm:"datetime 'delete_time'"`
}
Article model
func ArticleBySlug ¶ added in v0.0.3
ArticleBySlug returns article by slug.
func ArticlesByPage ¶
ArticlesByPage handles articles by page number.
func (*Article) UpdateByID ¶ added in v0.0.1
UpdateByID updates article data by ID.
type Option ¶
type Option struct {
ID uint64 `json:"option_id,omitempty" xorm:"bigint(20) notnull autoincr pk 'option_id'"`
Name string `json:"option_name" xorm:"varchar(255) notnull unique 'option_name'"`
Value string `json:"option_value" xorm:"longtext notnull 'option_value'"`
}
Option model, optional informations
type User ¶ added in v0.0.1
type User struct {
ID uint64 `json:"ID" xorm:"bigint(20) notnull autoincr pk 'ID'"`
Name string `json:"name" xorm:"varchar(18) notnull 'name'"`
NickName string `json:"nick_name" xorm:"varchar(25) notnull 'nick_name'"`
Password string `json:"password" xorm:"varchar(20) notnull 'password'"` // use raw password temporarily
Status int8 `json:"status" xorm:"tinyint(4) notnull default(0) 'status'"`
Email string `json:"email" xorm:"varchar(50) notnull 'email'"`
Role int8 `json:"role" xorm:"tinyint(4) notnull default(0) 'role'"`
CreateTime *time.Time `json:"create_time,omitempty" xorm:"datetime created notnull 'create_time'"`
UpdateTime *time.Time `json:"update_time,omitempty" xorm:"datetime updated notnull 'update_time'"`
DeleteTime *time.Time `json:"delete_time,omitempty" xorm:"datetime 'delete_time'"`
}
User model
func GetUserByName ¶ added in v0.0.2
GetByName returns an user by 'name' if it exist. Not including 'ID' field.
type WebAuthnCredential ¶ added in v0.0.1
type WebAuthnCredential struct {
ID int64 `json:"ID" xorm:"pk autoincr 'ID'"`
Name string `json:"name" xorm:"unique(s) 'name'"`
NickName string `json:"nick_name" xorm:"varchar(25) notnull 'nick_name'"`
UserID int64 `json:"user_id" xorm:"INDEX unique(s) notnull 'user_id'"`
CredentialID []byte `json:"credential_id" xorm:"INDEX VARBINARY(1024) notnull 'credential_id'"`
PublicKey []byte `json:"public_key" xorm:"notnull 'public_key'"`
AttestationType string `json:"attestation_type" xorm:"'attestation_type'"`
AAGUID []byte `json:"aaguid" xorm:"notnull 'aaguid'"`
SignCount uint32 `json:"sign_count" xorm:"BIGINT 'sign_count'"`
CloneWarning bool `json:"clone_warning" xorm:"'clone_warning'"`
Attachment string `json:"attachment" xorm:"'attachment'"`
CreateTime *time.Time `json:"create_time,omitempty" xorm:"datetime created notnull 'create_time'"`
UpdateTime *time.Time `json:"update_time,omitempty" xorm:"datetime updated notnull 'update_time'"`
DeleteTime *time.Time `json:"delete_time,omitempty" xorm:"datetime 'delete_time'"`
}
WebAuthnCredential represents the WebAuthn credential data.
func (WebAuthnCredential) Add ¶ added in v0.0.1
func (cred WebAuthnCredential) Add() bool
Add adds a new WebAuthn credential to `webauthn_credential` table.
func (WebAuthnCredential) Get ¶ added in v0.0.1
func (cred WebAuthnCredential) Get() []WebAuthnCredential
Get gets WebAuthn credential list by the given WebAuthnCredential condition.
func (WebAuthnCredential) TableName ¶ added in v0.0.1
func (cred WebAuthnCredential) TableName() string
TableName returns a better table name for WebAuthnCredential.