models

package
v0.0.0-...-102a4db Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Db is the global database reference
	Db *gorm.DB
)

Functions

func CloseDatabase

func CloseDatabase()

CloseDatabase closes the database

func DropAllTables

func DropAllTables()

DropAllTables drops all tables and relations, only works with local database in debug mode

func InitializeDatabase

func InitializeDatabase()

InitializeDatabase opens and migrates the database if necessary

func OpenDatabase

func OpenDatabase()

OpenDatabase opens the database and returns a handle

Types

type JSONMap

type JSONMap map[string]interface{}

JSONMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface

func (JSONMap) GormDBDataType

func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (JSONMap) GormDataType

func (m JSONMap) GormDataType() string

GormDataType gorm common data type

func (JSONMap) MarshalJSON

func (m JSONMap) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*JSONMap) Scan

func (m *JSONMap) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*JSONMap) UnmarshalJSON

func (m *JSONMap) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Transaction

type Transaction struct {
	gorm.Model
	Uid       string `gorm:"column:uid; index"`
	Kind      string `gorm:"column:kind"`
	Status    string `gorm:"column:status"`
	TxHashHex string `gorm:"column:tx_hash_hex"`
	Cost      string `gorm:"column:cost"`
}

Jump to

Keyboard shortcuts

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