db

package
v0.0.0-...-3a73874 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

* @Name: * @Descripttion: * @Warning: * @version: * @Author: moo * @Date: 2020-10-28 17:22:07 * @LastEditors: linzhengmao * @LastEditTime: 2025-01-20 17:24:58

* @Description: * @Author: linzhengmao * @Email: linzhengmao@126.com * @Date: 2025-02-18 19:11:02 * @LastEditTime: 2025-02-18 19:11:03 * @LastEditors: linzhengmao

Index

Constants

View Source
const (
	STLSTATE_FOREIGNKEY = 23503
)

Variables

View Source
var DB *gorm.DB
View Source
var ErrMustOne = errors.New("record must one")
View Source
var ErrNotFound = gorm.ErrRecordNotFound

var Err404 = errors.New("record not found")

Functions

func Close

func Close()

DbClose is a funciton

func GetDb

func GetDb() *gorm.DB

func GetSqlstate

func GetSqlstate(errInfo error) int

func Init

func Init(cfg *DbConfig) error

DbInit is a funciton

func InitTest

func InitTest() error

func IsNotFound

func IsNotFound(err error) bool

func IsNotOne

func IsNotOne(err error) bool

Types

type BaseModel

type BaseModel struct {
	ID uint `gorm:"primary_key" json:"id"`
	// CreatedAt time.Time      `json:"created_at"`
	// UpdatedAt time.Time      `json:"updated_at"`
	CreatedAt jtime.JTime    `json:"created_at"`
	UpdatedAt jtime.JTime    `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
}

type DbConfig

type DbConfig struct {
	Type     string // 0-sqllite 1-postgres 2-mysql
	DbName   string
	User     string
	Password string
	Host     string
	Port     int
	Path     string // for sqlite
	Debug    bool
}

type EnumBool

type EnumBool = byte
const (
	BOOL_FALSE EnumBool = 0x0
	BOOL_TRUE  EnumBool = 0x1
	BOOL_NONE  EnumBool = 0xFF
)

Jump to

Keyboard shortcuts

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