database

package
v3.28.0 Latest Latest
Warning

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

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

Documentation

Overview

Package database represents a connector to the sqlite storage backend to store persistent data from core and plugins

Index

Constants

This section is empty.

Variables

View Source
var ErrCoreMetaNotFound = errors.New("core meta entry not found")

ErrCoreMetaNotFound is the error thrown when reading a non-existent core_kv key

Functions

func CopyObjects added in v3.20.0

func CopyObjects(src, target *gorm.DB, objects ...any) (err error)

CopyObjects is a helper to copy elements of a given type from the src to the target GORM database interface

Types

type Connector

type Connector interface {
	Close() error
	CopyDatabase(src, target *gorm.DB) error
	DB() *gorm.DB
	DeleteCoreMeta(key string) error
	ReadCoreMeta(key string, value any) error
	StoreCoreMeta(key string, value any) error
	ReadEncryptedCoreMeta(key string, value any) error
	ResetEncryptedCoreMeta() error
	StoreEncryptedCoreMeta(key string, value any) error
	DecryptField(string) (string, error)
	EncryptField(string) (string, error)
	ValidateEncryption() error
}

Connector represents a database connection having some extra convenience methods

func GetTestDatabase

func GetTestDatabase(t *testing.T) Connector

GetTestDatabase returns a Connector to an in-mem SQLite DB

func New

func New(driverName, connString, encryptionSecret string) (c Connector, err error)

New creates a new Connector with the given driver and database

type LogWriter added in v3.20.0

type LogWriter struct{ io.Writer }

LogWriter implements a logger for the gorm logging

func NewLogrusLogWriterWithLevel added in v3.20.0

func NewLogrusLogWriterWithLevel(logger *logrus.Logger, level logrus.Level, dbDriver string) LogWriter

NewLogrusLogWriterWithLevel creates a new LogWriter with the given logrus.Logger and the specified logrus.Level

func (LogWriter) Print added in v3.20.0

func (l LogWriter) Print(a ...any)

Print implements the gorm.Logger interface

func (LogWriter) Printf added in v3.20.0

func (l LogWriter) Printf(format string, a ...any)

Printf implements the gorm.Logger interface

Jump to

Keyboard shortcuts

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