Documentation ¶ Index ¶ Constants func DB() *gorm.DB func DBFromCtx(ctx context.Context) *gorm.DB func Get() *dataSource func GetTransactionFromCtx(ctx context.Context) *gorm.DB func WithTransactionCtx(ctx context.Context, tx *gorm.DB) context.Context type PROVIDER type TransactionCtxKey Constants ¶ View Source const ( AppName = "datasource" ) Variables ¶ This section is empty. Functions ¶ func DB ¶ func DB() *gorm.DB func DBFromCtx ¶ added in v2.0.3 func DBFromCtx(ctx context.Context) *gorm.DB 从上下文中获取事物, 如果获取不到则直接返回 无事物的DB对象 func Get ¶ added in v2.0.8 func Get() *dataSource func GetTransactionFromCtx ¶ func GetTransactionFromCtx(ctx context.Context) *gorm.DB func WithTransactionCtx ¶ func WithTransactionCtx(ctx context.Context, tx *gorm.DB) context.Context Types ¶ type PROVIDER ¶ type PROVIDER string const ( PROVIDER_MYSQL PROVIDER = "mysql" PROVIDER_POSTGRES PROVIDER = "postgres" PROVIDER_SQLITE PROVIDER = "sqlite" ) type TransactionCtxKey ¶ type TransactionCtxKey struct{} Source Files ¶ View all Source files grom.go interface.go provider.go transaction.go Click to show internal directories. Click to hide internal directories.