CeresGorm

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

ceres-gorm

「仅发布」gorm模块

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertLevel

func ConvertLevel(level string) log.LogLevel

字符串转等级数值

func Register

func Register(name string, driverFunc DriverFunc)

注册驱动方法

Types

type Config

type Config struct {
	// 驱动
	Drive string
	// 连接字符串
	DNS string
	// 是否开启debug
	Debug bool
	// 最大空闲连接数
	MaxIdleConns int
	// 最大活动连接数
	MaxOpenConns int
	// 连接的最大存活时间
	ConnMaxLifetime time.Duration
	// 日志库
	Logger CeresLogger.Logger
	// 驱动适配器
	Dialector Dialector
	// 日志配置
	LogConfig
	// gorm的配置
	GormConfig
}

定义配置信息

func RawConfig

func RawConfig(key string) *Config

RawConfig 根据完整key解析配置信息

func ScanConfig

func ScanConfig(name string) *Config

ScanConfig 根据配置名解析配置

func (*Config) Build

func (c *Config) Build() *DB

Build 构建数据库

func (*Config) WithDriver

func (c *Config) WithDriver(dialect Dialector) *Config

WithDriver 设置驱动实例

func (*Config) WithLogger

func (c *Config) WithLogger(l CeresLogger.Logger) *Config

WithLogger 设置日志输出库

type DB

type DB = gorm.DB

func Open

func Open(dialect gorm.Dialector, c *Config) (*DB, error)

Open 打开链接

type Dialector

type Dialector = gorm.Dialector

type DriverFunc

type DriverFunc = func(dns string) Dialector

type GormConfig

type GormConfig gorm.Config

gorm的配置

type LogConfig

type LogConfig struct {
	// 慢日志阈值
	SlowThreshold time.Duration
	// 是否开启日志颜色区别
	Colorful bool
	// 日志等级
	LogLevel string
}

日志配置

Jump to

Keyboard shortcuts

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