ent

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDriver

func CreateDriver(driverName, dsn string, enableTrace, enableMetrics bool) (*entSql.Driver, error)

CreateDriver 创建数据库驱动

Types

type ClientInterface

type ClientInterface interface {
	Close() error
}

type ClientWrapper

type ClientWrapper[T ClientInterface] struct {
	// contains filtered or unexported fields
}

func NewEntClient

func NewEntClient[T ClientInterface](cfg *conf.Bootstrap, l *log.Helper, db T) *ClientWrapper[T]

NewEntClient 创建Ent ORM数据库客户端

func NewEntClientWrapper

func NewEntClientWrapper[T ClientInterface](db T, drv *entSql.Driver) *ClientWrapper[T]

func (*ClientWrapper[T]) Client

func (c *ClientWrapper[T]) Client() T

func (*ClientWrapper[T]) Close

func (c *ClientWrapper[T]) Close() error

Close 关闭数据库连接

func (*ClientWrapper[T]) DB

func (c *ClientWrapper[T]) DB() *sql.DB

func (*ClientWrapper[T]) Driver

func (c *ClientWrapper[T]) Driver() *entSql.Driver

func (*ClientWrapper[T]) Exec

func (c *ClientWrapper[T]) Exec(ctx context.Context, query string, args, v any) error

func (*ClientWrapper[T]) Query

func (c *ClientWrapper[T]) Query(ctx context.Context, query string, args, v any) error

Query 查询数据

func (*ClientWrapper[T]) SetConnectionOption

func (c *ClientWrapper[T]) SetConnectionOption(maxIdleConnections, maxOpenConnections int, connMaxLifetime time.Duration)

SetConnectionOption 设置连接配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳