database

package
v0.0.0-...-0a3e258 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(customPath ...string)

InitDB creates database handle and returns it.

Types

type Paste

type Paste struct {
	ID         string
	Submitter  string
	Content    []byte
	UploadDate time.Time
}

Paste contains object read from and send into database.

type PasteDB

type PasteDB struct {
	*sql.DB
	Directory string
	Filename  string
	MaxSize   float64
}

PasteDB is wrapper for sql database object with additional functions for pastes.

func GetDatabase

func GetDatabase() *PasteDB

GetDatabase returns database handle address.

func (*PasteDB) DeletePaste

func (db *PasteDB) DeletePaste(ID string) bool

DeletePaste removes paste with specified ID and returns true if deleted, false if not found.

func (*PasteDB) LoopCheckFileSizes

func (db *PasteDB) LoopCheckFileSizes()

LoopCheckFileSizes loops over isDBFileTooLarge

func (*PasteDB) ReadAllPastes

func (db *PasteDB) ReadAllPastes() []Paste

ReadAllPastes returns all pastes but without any content, just the metadata.

func (*PasteDB) ReadPaste

func (db *PasteDB) ReadPaste(ID string) Paste

ReadPaste gets paste with selected ID, otherwise returns empty Paste struct.

func (*PasteDB) StorePaste

func (db *PasteDB) StorePaste(item Paste)

StorePaste inserts new row with paste into database. Time from Paste struct isn't passed, it's generated inside database.

Jump to

Keyboard shortcuts

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