database

package
v0.0.0-...-3834a52 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package database handles the database singleton

Index

Constants

This section is empty.

Variables

View Source
var LoggerConfig = logger.Config{
	SlowThreshold:             time.Second,
	LogLevel:                  logger.Warn,
	IgnoreRecordNotFoundError: true,
	Colorful:                  true,
}

LoggerConfig is the logging config for Gorm

Functions

func CreateDBInstance

func CreateDBInstance(dbConfig *DBConfig) *gorm.DB

CreateDBInstance functions almost identically to GetDBInstance but lets you specify configuration

func CreateTestDBInstance

func CreateTestDBInstance()

func GetDBInstance

func GetDBInstance() *gorm.DB

GetDBInstance Get the singleton DB instance

func GetKey

func GetKey(key string) (models.APIKey, error)

func InitDB

func InitDB()

InitDB Initializes and migrates the DB ready for use by the server

func IsKeyValid

func IsKeyValid(key string) bool

Types

type DBConfig

type DBConfig struct {
	Driver string
	Host   string
	Port   int
	DBName string
	User   string
	Pass   string
}

DBConfig is an object that contains some db config

Jump to

Keyboard shortcuts

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