database

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB_HOST     = "localhost"
	DB_USER     = "tp_rest_api"
	DB_PASSWORD = "tp-rest-api-pwd"
	DB_NAME     = "threeport_api"
	DB_PORT     = "26257"
	DB_SSL_MODE = "disable"
)

Functions

func GetDbInterfaces

func GetDbInterfaces() []interface{}

Return all database init object interfaces.

func Init

func Init(autoMigrate bool, logger *zap.Logger) (*gorm.DB, error)

Init initializes the API database.

Types

type ZapLogger

type ZapLogger struct {
	Logger *zap.Logger
}

ZapLogger is a custom GORM logger that forwards log messages to a Zap logger.

func (*ZapLogger) Error

func (zl *ZapLogger) Error(ctx context.Context, msg string, data ...interface{})

Error overrides the standard GORM logger's Error method to forward log messages to the zap logger.

func (*ZapLogger) Info

func (zl *ZapLogger) Info(ctx context.Context, msg string, data ...interface{})

Info overrides the standard GORM logger's Info method to forward log messages to the zap logger.

func (*ZapLogger) LogMode

func (zl *ZapLogger) LogMode(level logger.LogLevel) logger.Interface

LogMode overrides the standard GORM logger's LogMode method to set the logger mode.

func (*ZapLogger) Trace

func (zl *ZapLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace overrides the standard GORM logger's Trace method to forward log messages to the zap logger.

func (*ZapLogger) Warn

func (zl *ZapLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn overrides the standard GORM logger's Warn method to forward log messages to the zap logger.

Jump to

Keyboard shortcuts

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