database

package
v0.7.63 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

View Source
const (
	POSTGRES = "postgres"
	SQLITE   = "sqlite"
)

Variables

View Source
var (
	ErrNoneDatabaseCode              = "meshkit-11126"
	ErrDatabaseOpenCode              = "meshkit-11127"
	ErrSQLMapUnmarshalJSONCode       = "meshkit-11128"
	ErrSQLMapUnmarshalTextCode       = "meshkit-11129"
	ErrSQLMapMarshalValueCode        = "meshkit-11130"
	ErrSQLMapUnmarshalScannedCode    = "meshkit-11131"
	ErrSQLMapInvalidScanCode         = "meshkit-11132"
	ErrClosingDatabaseConnectionCode = "meshkit-11133"
	ErrNoneDatabase                  = errors.New(ErrNoneDatabaseCode, errors.Alert, []string{"No Database selected"}, []string{}, []string{"database name is empty"}, []string{"Input a name for the database"})
	ErrSQLMapInvalidScan             = errors.New(ErrSQLMapInvalidScanCode, errors.Alert, []string{"invalid data type: expected []byte"}, []string{}, []string{}, []string{})
)

Functions

func ErrClosingDatabaseConnection added in v0.5.0

func ErrClosingDatabaseConnection(err error) error

ErrClosingDatabaseConnection represents the error which will occur when the database connection fails to get closed

func ErrDatabaseOpen

func ErrDatabaseOpen(err error) error

func ErrSQLMapMarshalValue added in v0.2.8

func ErrSQLMapMarshalValue(err error) error

ErrSQLMapMarshalValue represents the error which will occur when the native SQL driver will fail to marshal the value

func ErrSQLMapUnmarshalJSON added in v0.2.8

func ErrSQLMapUnmarshalJSON(err error) error

ErrSQLMapUnmarshalJSON represents the error which will occur when the native SQL driver will fail to unmarshal the JSON

func ErrSQLMapUnmarshalScanned added in v0.2.8

func ErrSQLMapUnmarshalScanned(err error) error

ErrSQLMapUnmarshalScanned represents the error which will occur when the native SQL driver will fail to unmarshal the scanned data

func ErrSQLMapUnmarshalText added in v0.2.8

func ErrSQLMapUnmarshalText(err error) error

ErrSQLMapUnmarshalJSON represents the error which will occur when the native SQL driver will fail to unmarshal the text

Types

type Handler

type Handler struct {
	*gorm.DB
	*sync.Mutex
}

func New

func New(opts Options) (Handler, error)

func (*Handler) DBClose added in v0.5.0

func (h *Handler) DBClose() error

type Map added in v0.2.8

type Map map[string]interface{}

Map type is an alias for map[string]interface{}

It implements native SQL driver interfaces and hence can be used for SQL json or jsonb types as a drop in replacement of golang native maps

func (Map) Interface added in v0.2.8

func (m Map) Interface() interface{}

Interface implements the nulls.nullable interface.

func (*Map) Scan added in v0.2.8

func (m *Map) Scan(src interface{}) error

Scan implements the sql.Scanner interface. It allows to read the map from the database value.

func (*Map) UnmarshalJSON added in v0.2.8

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

UnmarshalJSON will unmarshall JSON value into the map representation of this value.

func (Map) UnmarshalText added in v0.2.8

func (m Map) UnmarshalText(text []byte) error

UnmarshalText will unmarshall text value into the map representation of this value.

func (Map) Value added in v0.2.8

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

Value implements the driver.Valuer interface. It allows to convert the map to a driver.value.

type Model

type Model struct {
	ID        string `json:"id,omitempty" gorm:"primarykey"`
	CreatedAt string `json:"created_at,omitempty" gorm:"index"`
	UpdatedAt string `json:"updated_at,omitempty" gorm:"index"`
	DeletedAt string `json:"deleted_at,omitempty" gorm:"index"`
}

type Options

type Options struct {
	Username string `json:"username,omitempty"`
	Host     string `json:"host,omitempty"`
	Port     string `json:"port,omitempty"`
	Password string `json:"password,omitempty"`
	Filename string `json:"filename,omitempty"`
	Engine   string `json:"engine,omitempty"`
	Logger   logger.Handler
}

Jump to

Keyboard shortcuts

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