DB

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

* @Author: i@douxuefeng.cn * @Date: 2023-04-15 09:18:31 * @LastEditTime: 2023-04-15 09:20:44 * @LastEditors: i@douxuefeng.cn * @Description: * @FilePath: /nodes/Volumes/Data/jobs/go-utils/DB/sqlite.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDb

func CloseDb()

func GetDb

func GetDb() *gorm.DB

func InitDb added in v0.2.0

func InitDb(opt *Opt) error

func InitSqlite added in v0.2.6

func InitSqlite(opt *SqliteOpt) error

Types

type BaseModel

type BaseModel struct {
	Id        int64           `json:"id"  gorm:"primaryKey"`
	CreatedAt *time.Time      `json:"created_at,omitempty" `
	UpdatedAt *time.Time      `json:"updated_at,omitempty" `
	DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" `
}

添加软删除

type CommModel

type CommModel struct {
	Id        int64      `json:"id"  gorm:"primaryKey"`
	CreatedAt *time.Time `json:"created_at,omitempty" `
	UpdatedAt *time.Time `json:"updated_at,omitempty" `
}

type DBCondition added in v0.2.1

type DBCondition func(db *gorm.DB) *gorm.DB

func GetNameLikeCondition added in v0.2.1

func GetNameLikeCondition(name string) DBCondition

func GetOrder added in v0.2.1

func GetOrder(order string) DBCondition

func GetTitleLikeCondition added in v0.2.1

func GetTitleLikeCondition(title string) DBCondition

func Paginate

func Paginate(page, pageSize int) DBCondition

type Opt added in v0.2.0

type Opt struct {
	Dsn                                      string //master
	MaxIdle                                  int
	MaxOpen                                  int
	LogMode                                  logger.LogLevel
	Models                                   []any
	EnableMigrate                            bool
	DisableForeignKeyConstraintWhenMigrating bool
}

type SqliteOpt added in v0.2.6

type SqliteOpt struct {
	SqlFile                           string
	MaxIdle                           int
	MaxOpen                           int
	LogMode                           logger.LogLevel
	Models                            []any
	DisableForeignKeyCheckWhenMigrate bool
	EnableMigrate                     bool
}

Jump to

Keyboard shortcuts

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