db

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllFiles

func GetAllFiles(db DBQuery) ([]iface.File, error)

func GetAllTokens

func GetAllTokens(db DBQuery) ([]iface.Token, error)

func GetExpiredFiles

func GetExpiredFiles(db DBQuery, limit int) ([]iface.File, error)

func GetFileById

func GetFileById(db DBQuery, id string) (*iface.File, error)

func GetFilesByHash

func GetFilesByHash(db DBQuery, hash string) ([]iface.File, error)

files are stored many to one. 1 file on disk can represent many files in the db

func GetFilesByToken

func GetFilesByToken(db DBQuery, token string) ([]iface.File, error)

func GetTokenById

func GetTokenById(db DBQuery, id string) (*iface.Token, error)

func InsertFile

func InsertFile(db DBQuery, token, name, hash, mime string, size int64, expire time.Duration) (*iface.File, error)

func InsertToken

func InsertToken(db DBQuery, isAdmin bool) (*iface.Token, error)

func RemoveFile

func RemoveFile(db DBQuery, id string) (*iface.File, error)

func RemoveToken

func RemoveToken(db DBQuery, id string) (*iface.Token, error)

Types

type DBHandler

type DBHandler struct {
	// contains filtered or unexported fields
}

func OpenLiteDB

func OpenLiteDB(dbPath string) (*DBHandler, error)

func (*DBHandler) Close

func (db *DBHandler) Close() error

func (*DBHandler) Query

func (db *DBHandler) Query(query string, args ...any) (*sql.Rows, error)

func (*DBHandler) Setup

func (db *DBHandler) Setup() error

func (*DBHandler) Transaction

func (db *DBHandler) Transaction(transaction func(*sql.Tx) error) (err error)

calls transaction, if transaction returns a non-nil error the transaction is rolled back. otherwise the transaction is committed

type DBQuery

type DBQuery interface {
	Query(query string, args ...any) (*sql.Rows, error)
}

Jump to

Keyboard shortcuts

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