models

package
v0.0.0-...-eb6cbd3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArticleNum

func ArticleNum() (int64, error)

Get the total number of articles in the database

Types

type Article

type Article struct {
	Id       int
	Title    string `orm:"unique"`
	Subtitle string `orm:"null"`
	Author   string
	//	Tags       [5]string
	Text       string `orm:"-"`
	Createtime int64
	Status     bool
}

func ListArticleByPage

func ListArticleByPage(numPerPage, pageIndex int64) ([]*Article, error)

NOTICE : I originally set the type of "articles" as "*[]*Article" ,which is also accepted by the orm function ,HOWEVER,error about reflect occurs, so I change the type to "[]*Article", and then everything works just fine

func (*Article) Delete

func (u *Article) Delete() error

func (*Article) Exist

func (u *Article) Exist() bool

func (*Article) GetById

func (u *Article) GetById() (*Article, error)

func (*Article) Insert

func (u *Article) Insert() (Id int64, err error)

type Pagination

type Pagination struct {
	HasPrevious, HasNext   bool
	PageIndex              int
	PreviousLink, NextLink string
}

func (*Pagination) Set

func (p *Pagination) Set(pageIndex, numPerPage, pagenum int64)

Alright,I admit,it's NOT very good to write a function containing specific url in "models"

type User

type User struct {
	Id         int
	Username   string `orm:"unique"`
	Password   string
	Createtime int64
	Status     bool
}

func (*User) Exist

func (u *User) Exist() bool

func (*User) GetByName

func (u *User) GetByName() (*User, error)

func (*User) Insert

func (u *User) Insert() (Id int64, err error)

Jump to

Keyboard shortcuts

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