database

package
v1.0.0-rc17 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package database represents the data layer of S&D.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(from Database, to Database) error

Migrate copies all data from one database to another. Currently, no advanced handling is done, so migration is only done optimistically.

Types

type DataSourceEntry

type DataSourceEntry struct {
	snd.DataSource
	Count int `json:"count"`
}

DataSourceEntry represents a S&D data source together with the amount of entries it has.

type Database

type Database interface {
	Close() error

	GetSettings() (snd.Settings, error)
	SaveSettings(settings snd.Settings) error

	GetLogs(hours int) ([]log.Entry, error)
	AddLog(e log.Entry) error

	GetTemplate(id string) (snd.Template, error)
	SaveTemplate(template snd.Template) error
	DeleteTemplate(id string) error
	GetTemplates() ([]TemplateEntry, error)

	GetEntries(id string) ([]snd.Entry, error)
	GetEntry(id string, eid string) (snd.Entry, error)
	CountEntries(id string) (int, error)
	SaveEntry(id string, entry snd.Entry) error
	SaveEntries(id string, entry []snd.Entry) error
	DeleteEntry(id string, eid string) error
	DeleteEntries(id string) error

	GetGenerator(id string) (snd.Generator, error)
	SaveGenerator(generator snd.Generator) error
	DeleteGenerator(id string) error
	GetGenerators() ([]snd.Generator, error)

	SaveSource(ds snd.DataSource) error
	DeleteSource(id string) error
	GetSource(id string) (snd.DataSource, error)
	GetSources() ([]DataSourceEntry, error)

	GetKey(key string) (string, error)
	SetKey(key string, value string) error
	DeleteKey(key string) error
	GetKeysPrefix(prefix string) ([]string, error)
}

Database represents all database functions that are needed for S&D to work.

type TemplateEntry

type TemplateEntry struct {
	snd.Template
	Count int `json:"count"`
}

TemplateEntry represents a S&D template together with the amount of entries it has.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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