orm

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBaseConfig

func GetBaseConfig(c framework.Container) *contract.DBConfig

GetBaseConfig 读取database.yaml根目录结构

func NewYgoGorm

func NewYgoGorm(params ...interface{}) (interface{}, error)

NewYgoGorm 代表实例化Gorm

func WithConfigPath

func WithConfigPath(configPath string) contract.DBOption

WithConfigPath 加载配置文件地址

func WithDryRun

func WithDryRun() contract.DBOption

WithDryRun 设置空跑模式

func WithFullSaveAssociations

func WithFullSaveAssociations() contract.DBOption

WithFullSaveAssociations 设置保存时候关联

func WithGormConfig

func WithGormConfig(gormConfig *gorm.Config) contract.DBOption

WithGormConfig 表示自行配置Gorm的配置信息

Types

type GormProvider

type GormProvider struct {
}

GormProvider 提供App的具体实现方法

func (*GormProvider) Boot

func (h *GormProvider) Boot(container framework.Container) error

Boot 启动调用

func (*GormProvider) IsDefer

func (h *GormProvider) IsDefer() bool

IsDefer 是否延迟初始化

func (*GormProvider) Name

func (h *GormProvider) Name() string

Name 获取字符串凭证

func (*GormProvider) Params

func (h *GormProvider) Params(container framework.Container) []interface{}

Params 获取初始化参数

func (*GormProvider) Register

func (h *GormProvider) Register(container framework.Container) framework.NewInstance

Register 注册方法

type OrmLogger

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

OrmLogger orm的日志实现类, 实现了gorm.Logger.Interface

func NewOrmLogger

func NewOrmLogger(logger contract.Log) *OrmLogger

NewOrmLogger 初始化一个ormLogger,

func (*OrmLogger) Error

func (o *OrmLogger) Error(ctx context.Context, s string, i ...interface{})

Error 对接hade的Error输出

func (*OrmLogger) Info

func (o *OrmLogger) Info(ctx context.Context, s string, i ...interface{})

Info 对接hade的info输出

func (*OrmLogger) LogMode

func (o *OrmLogger) LogMode(level logger.LogLevel) logger.Interface

LogMode 什么都不实现,日志级别完全依赖hade的日志定义

func (*OrmLogger) Trace

func (o *OrmLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

Trace 对接hade的Trace输出

func (*OrmLogger) Warn

func (o *OrmLogger) Warn(ctx context.Context, s string, i ...interface{})

Warn 对接hade的Warn输出

type YgoGorm

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

func (*YgoGorm) GetDB

func (app *YgoGorm) GetDB(option ...contract.DBOption) (*gorm.DB, error)

GetDB 获取DB实例

Jump to

Keyboard shortcuts

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