orm

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 13 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 NewNiceGorm

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

NewNiceGorm 代表实例化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 {
	// contains filtered or unexported fields
}

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 LoggerORM

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

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

func NewOrmLogger

func NewOrmLogger(logger contract.Log) *LoggerORM

NewOrmLogger 初始化一个ormLogger,

func (*LoggerORM) Error

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

Error 对接nice的Error输出

func (*LoggerORM) Info

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

Info 对接nice的info输出

func (*LoggerORM) LogMode

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

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

func (*LoggerORM) Trace

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

Trace 对接nice的Trace输出

func (*LoggerORM) Warn

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

Warn 对接nice的Warn输出

type NiceGorm

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

NiceGorm 代表nice框架的orm实现

func (*NiceGorm) GetDB

func (app *NiceGorm) 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