model

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: Zlib Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddArticle

func AddArticle(article *Article) bool

AddArticle handles and add article.

func AddOption

func AddOption(option *Option) (bool, error)

AddOption adds option to DB `option` table, return boolean value. If result returned is `true`, insert option data to DB successful.

func ArticleExist

func ArticleExist(id uint64) bool

ArticleExist if article exist

func ArticlesCount

func ArticlesCount() int

ArticlesCount returns count number.

func DeleteOptionByName

func DeleteOptionByName(optionName string) (bool, error)

DeleteOptionByName deletes an Option by 'option_name'. If result returned is `true`, delete option data successful.

func InitTables

func InitTables()

func OptionExist

func OptionExist(optionName string) (bool, error)

OptionExist if the option_name of option exist If `true`, this option already exists.

func UpdateOptionByName

func UpdateOptionByName(option Option) (bool, error)

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 ArticleByID

func ArticleByID(id uint64) (*Article, bool)

ArticleByID returns article by ID.

func ArticleBySlug

func ArticleBySlug(slug string) (*Article, bool)

ArticleBySlug returns article by slug.

func ArticlesByPage

func ArticlesByPage(limit int, page int) []Article

ArticlesByPage handles articles by page number.

func (*Article) UpdateByID

func (a *Article) UpdateByID() bool

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

func GetAllOptions

func GetAllOptions() ([]Option, error)

GetAllOptions returns all options.

func GetOptionByName

func GetOptionByName(optionName string) (bool, Option, error)

GetOptionByName returns an Option by 'option_name' if it exist. Only include 'option_value' field.

type User

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

func GetUserByName(name string) (bool, User, error)

GetByName returns an user by 'name' if it exist. Not including 'ID' field.

func (*User) Add

func (u *User) Add() (bool, error)

Add adds user to `user` table.

func (*User) Delete

func (u *User) Delete() (bool, error)

Delete deletes an User.

type WebAuthnCredential

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

func (cred WebAuthnCredential) Add() bool

Add adds a new WebAuthn credential to `webauthn_credential` table.

func (WebAuthnCredential) Get

Get gets WebAuthn credential list by the given WebAuthnCredential condition.

func (WebAuthnCredential) TableName

func (cred WebAuthnCredential) TableName() string

TableName returns a better table name for WebAuthnCredential.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL