database

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 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

View Source
var DB *gorm.DB

DB 全局数据库实例,模块通过 database.DB 直接使用

Functions

func BuildTableName

func BuildTableName(model interface{}, prefix string) string

BuildTableName 调用 GORM 默认命名策略生成表名,并添加模块前缀

BuildTableName(&Vote{}, "starvote_")  →  "starvote_votes"
BuildTableName(&Rating{}, "starvote_") →  "starvote_ratings"

func Close

func Close() error

Close 关闭数据库连接

func Init

func Init(cfg config.DatabaseConfig) error

Init 初始化数据库连接

func RegisterModel

func RegisterModel(model interface{})

RegisterModel 收集各模块的 GORM Model(在模块 init() 中调用,在 DB.Init 之前)

Types

This section is empty.

Jump to

Keyboard shortcuts

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