models

package
v0.0.0-...-5845281 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Id          int       `orm:"pk;auto"`
	ArtiName    string    `orm:"size(32);default(一篇好文章)"`
	Atime       time.Time `orm:"auto_now;type(datetime)"`
	Acount      int       `orm:"default(0);null"`
	Acontent    string    `orm:"null"` //默认不能为NULL, 这样设置之后可以为NULL
	Aimg        string
	User        []*User      `orm:"reverse(many)"`               //多对多
	ArticleType *ArticleType `orm:"rel(fk)"`                     //一对多
	BeginTime   time.Time    `orm:"auto_now_add;type(datetime)"` //第一次保存时才设置时间
	UpdateTime  time.Time    `orm:"auto_now;type(date)"`         //保存时都会对时间自动更新
}

----------------------一对多begin--------

type ArticleType

type ArticleType struct {
	Id       int
	TypeName string     `orm:"size(16)"`
	Article  []*Article `orm:"reverse(many)"`
}

type Testtable

type Testtable struct {
	Id    int     `orm:"pk;auto"`
	Money float64 `orm:"digits(12);decimals(2);default(0.00)"` //总共12位,小数点2位
}

-----------------------一对多end---------

type User

type User struct {
	Id      int    `orm:"pk;auto"`
	Name    string `orm:"unique"`
	Pwd     string
	Article []*Article `orm:"rel(m2m)"`
}

----------------------多对多begin--------

Jump to

Keyboard shortcuts

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