db

package
v0.0.0-...-fa633b5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        int64 `gorm:"not null;primaryKey;autoIncrement;column:id"`
	CreatedAt int   `gorm:"type:int(11);autoCreateTime;unsigned;not null;column:create_time"`
	UpdatedAt int   `gorm:"type:int(11);autoUpdateTime;unsigned;not null;column:update_time"`
}

don't use soft delete

type Config

type Config struct {
	Host, Port, User, Pass, DBName, LogLevel string
}

type WrapDb

type WrapDb struct {
	*gorm.DB
	// contains filtered or unexported fields
}

wrap for *gorm.DB

func NewDB

func NewDB(cfg *Config) (wrapDb *WrapDb, err error)

func NewWrapDb

func NewWrapDb(db *gorm.DB) *WrapDb

func (*WrapDb) CommitTransaction

func (d *WrapDb) CommitTransaction() error

Only for transactional dao calls

func (*WrapDb) NewTransaction

func (d *WrapDb) NewTransaction() *WrapDb

transaction begin,must call rollback or commitTransaction after call this

func (*WrapDb) RollbackTransaction

func (d *WrapDb) RollbackTransaction() error

Only for transactional dao calls

Jump to

Keyboard shortcuts

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