models

package
v0.0.0-...-c3c07ef Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableLocation = "tb_location"
)

表名

View Source
const (
	TableUser = "tb_user"
)

表名

Variables

This section is empty.

Functions

func CreateDB

func CreateDB(username, password, host string, port int, dbname string, maxIdle, maxOpen int) *gorm.DB

CreateDB 初始化MYSQL实例

func DB

func DB() *gorm.DB

DB 返回一个MYSQL的空闲连接

func Session

func Session() *gorm.DB

Session 返回一个Transation Must remember to commit or rollback

Types

type Location

type Location struct {
	ID        int64   `gorm:"primary_key;column:id"`
	UserID    int64   `gorm:"column:user_id"`
	Latitude  float64 `gorm:"column:latitude;type:DECIMAL(12, 10)"`
	Longitude float64 `gorm:"column:longitude;type:DECIMAL(13, 10)"`
	GeoHash   string  `gorm:"column:geo_hash;index"`

	TimeMixin
}

Location 用户地理位置.

func (Location) TableName

func (Location) TableName() string

TableName 表名.

type TimeMixin

type TimeMixin struct {
	UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP"`
	CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP"`
}

TimeMixin mixin

type User

type User struct {
	ID       int64  `gorm:"primary_key;column:id"`
	Username string `gorm:"column:username"`
	Sex      string `gorm:"column:sex"`

	TimeMixin
}

User 用户信息.

func (User) TableName

func (User) TableName() string

TableName 表名.

Jump to

Keyboard shortcuts

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