dborm

package module
v0.0.0-...-803ac38 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMySQL      = "mysql"
	DriverSqlite3    = "sqlite3"
	DriverPostgreSQL = "postgresql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine 定义 ORM 引擎的数据结构

func NewEngine

func NewEngine(driverName, dbSource string) (eng *Engine, err error)

NewEngine 创建一个 ORM 引擎

func (*Engine) Close

func (own *Engine) Close() error

Close 关闭引擎

func (*Engine) NewSession

func (own *Engine) NewSession(model ...any) *session.Session

NewSession 新建一个会话

func (*Engine) SetMaxIdleConns

func (own *Engine) SetMaxIdleConns(num int)

func (*Engine) SetMaxOpenConns

func (own *Engine) SetMaxOpenConns(num int)

func (*Engine) Transact

func (own *Engine) Transact(fn TxFunc) (res any, err error)

Transact executes sql wrapped in a transaction, then automatically commit if no error occurs

type TxFunc

type TxFunc func(*session.Session) (any, error)

TxFunc will be called between tx.Begin() and tx.Commit()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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