database

package
v1.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists added in v1.0.0

func Exists(dbPath string) (bool, error)

Exists checks if the database folder exists and is not empty.

func NewWithDefaultSettings added in v1.0.0

func NewWithDefaultSettings(path string, createDatabaseIfNotExists bool, log *logger.Logger) (*gorm.DB, error)

Types

type Engine

type Engine string
const (
	EngineUnknown Engine = "unknown"
	EngineAuto    Engine = "auto"
	EngineSQLite  Engine = "sqlite"
)

func CheckEngine added in v1.0.0

func CheckEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine ...Engine) (Engine, error)

CheckEngine checks if the correct database engine is used. This function stores a so called "database info file" in the database folder or checks if an existing "database info file" contains the correct engine. Otherwise the files in the database folder are not compatible.

func EngineAllowed added in v1.0.0

func EngineAllowed(dbEngine Engine, allowedEngines ...Engine) (Engine, error)

EngineAllowed checks if the database engine is allowed.

func EngineFromString added in v1.0.0

func EngineFromString(engineStr string) (Engine, error)

EngineFromString parses an engine from a string. Returns an error if the engine is unknown.

func EngineFromStringAllowed added in v1.0.0

func EngineFromStringAllowed(dbEngineStr string, allowedEngines ...Engine) (Engine, error)

EngineFromStringAllowed parses an engine from a string and checks if the database engine is allowed.

func LoadEngineFromFile added in v1.0.0

func LoadEngineFromFile(path string) (Engine, error)

LoadEngineFromFile returns the engine from the "database info file".

Jump to

Keyboard shortcuts

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