database

package
v0.0.0-...-876d066 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(addr, dbname, user, passwd string) *sql.DB

func ConnectGormDB

func ConnectGormDB() error

func InitDB

func InitDB(addr, dbname, user, passwd string) (*gorm.DB, error)

func RunGorm

func RunGorm()

func RunSql

func RunSql()

Types

type Dao

type Dao struct {
	DB *sql.DB
}

func NewDao

func NewDao() *Dao

func (*Dao) Save

func (dao *Dao) Save(users []entity.User) error

func (*Dao) Select

func (dao *Dao) Select(users *[]entity.User) error

select query all User

type GormDao

type GormDao struct {
	DB *gorm.DB
}

func NewGormDao

func NewGormDao() *GormDao

func (*GormDao) GormSave

func (dao *GormDao) GormSave(users []entity.User) error

func (*GormDao) GormSelect

func (dao *GormDao) GormSelect() ([]entity.User, error)

select query all User

type User

type User struct {
	Id         int64     `gorm:"column:id;primary_key" json:"id"`
	AddTime    time.Time `gorm:"column:add_time" json:"add_time"`
	UpdateTime time.Time `gorm:"column:update_time" json:"update_time"`
	Name       string    `gorm:"column:name" json:"name"`
	Birthday   string    `gorm:"column:birthday" json:"birthday"`
}

Jump to

Keyboard shortcuts

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