db

package
v0.0.0-...-29e02a0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

* @Name: * @Descripttion: * @Warning: * @version: * @Author: moo * @Date: 2020-10-28 17:22:07 * @LastEditors: moo * @LastEditTime: 2024-01-10 20:36:47

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
}

Jump to

Keyboard shortcuts

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