orm

package
v0.0.0-...-69154b6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`
}

type ORM

type ORM struct {
	Dialect          string `val:"${db.dialect}"`
	URL              string `val:"${db.url}"`
	TablePrefix      string `val:"${db.table_prefix}"`
	PhysicalDeletion bool   `val:${db.physical_deletion}`
	DB               *gorm.DB
}

func (*ORM) Init

func (s *ORM) Init(model ...interface{}) error

func (*ORM) Page

func (s *ORM) Page(page ORMPage) *Page

func (*ORM) Tx

func (s *ORM) Tx(callback func(db *gorm.DB) error) error

Transaction

type ORMPage

type ORMPage struct {
	PageNum  int
	PageSize int
	OrderBy  string
	Where    ORMWhere
	Result   interface{}
}

type ORMWhere

type ORMWhere struct {
	Has   bool
	Cond  string
	Param []interface{}
}

func Where

func Where(where string, params ...interface{}) ORMWhere

type Page

type Page struct {
	List       interface{} `json:"list"`
	PageNum    int         `json:"page_num"`
	PageSize   int         `json:"page_size"`
	TotalPage  int         `json:"total_page"`
	TotalCount int         `json:"total_count"`
}

Jump to

Keyboard shortcuts

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