database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package database 提供数据库连接和管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path        string
	Debug       bool
	MaxOpenConn int
	MaxIdleConn int
}

Config 数据库配置

type Manager

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

Manager 数据库管理器

func New

func New(cfg Config, zapLogger *zap.Logger) (*Manager, error)

New 创建数据库管理器

func (*Manager) AutoMigrate

func (m *Manager) AutoMigrate(models ...interface{}) error

AutoMigrate 自动迁移数据库表

func (*Manager) Close

func (m *Manager) Close() error

Close 关闭数据库连接

func (*Manager) DB

func (m *Manager) DB() *gorm.DB

DB 获取 GORM 数据库实例

func (*Manager) HealthCheck

func (m *Manager) HealthCheck() error

HealthCheck 健康检查

func (*Manager) Stats

func (m *Manager) Stats() map[string]interface{}

Stats 获取数据库统计信息

func (*Manager) Transaction

func (m *Manager) Transaction(fc func(tx *gorm.DB) error) error

Transaction 执行事务

Jump to

Keyboard shortcuts

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