orm

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 14 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 NewHadeGorm

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

NewHadeGorm 代表实例化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(f func(options *contract.DBConfig)) 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 HadeGorm

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

HadeGorm 代表hade框架的orm实现

func (*HadeGorm) CanConnect added in v1.0.6

func (app *HadeGorm) CanConnect(ctx context.Context, db *gorm.DB) (bool, error)

func (*HadeGorm) GetDB

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

GetDB 获取DB实例

func (*HadeGorm) GetTableColumns added in v1.0.6

func (app *HadeGorm) GetTableColumns(ctx context.Context, db *gorm.DB, table string) ([]contract.TableColumn, error)

func (*HadeGorm) GetTables added in v1.0.6

func (app *HadeGorm) GetTables(ctx context.Context, db *gorm.DB) ([]string, error)

func (*HadeGorm) HasTable added in v1.0.6

func (app *HadeGorm) HasTable(ctx context.Context, db *gorm.DB, table string) (bool, error)

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输出

Jump to

Keyboard shortcuts

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