persistence

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 3 Imported by: 7

README

golang orm

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DriverMysql = Driver{"mysql", orm.DRMySQL}
View Source
var DriverOracle = Driver{"oracle", orm.DROracle}
View Source
var DriverPostgres = Driver{"postgres", orm.DRPostgres}
View Source
var DriverSqlite = Driver{"sqlite3", orm.DRSqlite}
View Source
var DriverTiDB = Driver{"tidb", orm.DRTiDB}

Functions

func CheckErr

func CheckErr(err error) error

func InitDatabase added in v1.2.0

func InitDatabase(config BaseConfig) (err error)

func InitOrm

func InitOrm(config BaseConfig) (err error)

func RegisterDataBase added in v1.2.0

func RegisterDataBase(init bool, aliasName, driverName, dataSource string, params ...orm.DBOption) (err error)

func RegisterDatabase added in v1.2.1

func RegisterDatabase(config BaseConfig) (err error)

func RegisterDriver added in v1.2.0

func RegisterDriver(driver Driver) (err error)

func RegisterModels added in v1.2.0

func RegisterModels(models ...interface{})

Types

type BaseConfig

type BaseConfig struct {
	// contains filtered or unexported fields
}

func (*BaseConfig) MaxConn added in v1.1.1

func (b *BaseConfig) MaxConn(n int)

func (*BaseConfig) MaxIdle added in v1.1.1

func (b *BaseConfig) MaxIdle(n int)

func (*BaseConfig) RegisterModel

func (b *BaseConfig) RegisterModel(models ...interface{})

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

type DriverType

type DriverType orm.DriverType

DriverType RegisterModel

type MysqlConfig

type MysqlConfig struct {
	InitDb    bool
	AliasName string
	UserName  string
	Password  string
	Host      string
	Port      int
	MaxIdle   int
	MaxConn   int
	DbName    string
}

func (*MysqlConfig) Build

func (c *MysqlConfig) Build() (b BaseConfig)

type OrmContext

type OrmContext struct {
	Context orm.Ormer
}

func New added in v1.1.0

func New() *OrmContext

func NewOrm added in v1.2.0

func NewOrm(aliasName string) *OrmContext

func (*OrmContext) Transaction

func (o *OrmContext) Transaction(h func(TxContext) error) (err error)

type Pager

type Pager struct {
	PageNo     int // start with 1
	PageSize   int // > 0
	TotalPage  int
	TotalCount int
}

func BuildPager

func BuildPager(pageNo int, pageSize int) Pager

func (*Pager) GetLimit

func (p *Pager) GetLimit() (limit int, start int)

func (*Pager) IsFirstPage

func (p *Pager) IsFirstPage() bool

func (*Pager) IsLastPage

func (p *Pager) IsLastPage() bool

func (*Pager) Next

func (p *Pager) Next()

func (*Pager) SetPageNo

func (p *Pager) SetPageNo(no int)

func (*Pager) SetTotal

func (p *Pager) SetTotal(total int)

type PostgresConfig

type PostgresConfig struct {
	InitDb    bool
	AliasName string
	UserName  string
	Password  string
	Host      string
	Port      int
	DbName    string
	MaxIdle   int
	MaxConn   int
	SSL       string
}

func (*PostgresConfig) Build

func (c *PostgresConfig) Build() (b BaseConfig)

type SqliteConfig

type SqliteConfig struct {
	Database  string
	AliasName string
	InitDb    bool
}

func (*SqliteConfig) Build

func (c *SqliteConfig) Build() (b BaseConfig)

type TxContext added in v1.1.1

type TxContext struct {
	Context orm.TxOrmer
}

Jump to

Keyboard shortcuts

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