gormx

package
v0.0.0-...-6606c74 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisConnect

func DisConnect() error

func GetGormDB

func GetGormDB() *gorm.DB

func Initialize

func Initialize(dbDrv, dbSrc string)

Types

type BaseFields

type BaseFields struct {
	Id         string    `json:"id" gorm:"column:id;type:char(25);primaryKey;<-:create"`
	CreateTime time.Time `json:"create_time" gorm:"column:create_time;autoCreateTime"`
	UpdateTime time.Time `json:"update_time" gorm:"column:update_time;<-:create;autoUpdateTime"`
}

func CreateBaseField

func CreateBaseField() BaseFields

func (*BaseFields) BeforeCreate

func (f *BaseFields) BeforeCreate(tx *gorm.DB) (err error)

func (*BaseFields) GetCreatedTime

func (f *BaseFields) GetCreatedTime() time.Time

func (*BaseFields) GetId

func (f *BaseFields) GetId() string

func (*BaseFields) GetUpdatedTime

func (f *BaseFields) GetUpdatedTime() time.Time

func (*BaseFields) SetUpdatedTime

func (f *BaseFields) SetUpdatedTime(t time.Time)

type BaseRepository

type BaseRepository[T any] interface {
	CreateOne(context.Context, *T) error
	GetOneById(context.Context, string) (*T, error)
	UpdateOneById(context.Context, string, *T) error
	DeleteOneById(context.Context, string) error
	InitDB() error
}

type DriverType

type DriverType int
const (
	Unknown DriverType = iota - 1
	Postgres
	Mysql
	Sqlite
)

func ParseDriverType

func ParseDriverType(dt string) DriverType

func (DriverType) String

func (d DriverType) String() string

Jump to

Keyboard shortcuts

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