orm

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 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 NewHeroGorm

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

NewHeroGorm 代表实例化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 是否延迟初始化,orm需要延迟加载实例,因为这个不是基础服务

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 HeroGorm

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

HeroGorm 代表hero框架的orm实现

func (*HeroGorm) GetDB

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

GetDB 获取DB实例

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 对接hero的Error输出

func (*OrmLogger) Info

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

Info 对接hero的info输出

func (*OrmLogger) LogMode

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

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

func (*OrmLogger) Trace

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

Trace 对接hero的Trace输出

func (*OrmLogger) Warn

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

Warn 对接hero的Warn输出

Jump to

Keyboard shortcuts

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