dbhandle

package
v0.0.0-...-8120768 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

func CreateLocalDB

func CreateLocalDB(dbName string, newTableName string) (*DB, error)

Creates a local database file in the same directory as executable if does not exist already. Creates a table with such structure: (id PRIMARY KEY, title TEXT, text TEXT), which represents underlying fields of `RandomData`

func (*DB) Create

func (db *DB) Create(rd randomdata.RandomData) error

Create a new `RandomData` row in db

func (*DB) DeleteSpecific

func (db *DB) DeleteSpecific(id uint) error

Delete `RandomData` from db with given id

func (*DB) GetEverything

func (db *DB) GetEverything() ([]*randomdata.RandomData, error)

Collect and return all rows in db

func (*DB) GetSpecific

func (db *DB) GetSpecific(id uint) (*randomdata.RandomData, error)

Get `RandomData` from db with given id

func (*DB) HandleGlobalWeb

func (db *DB) HandleGlobalWeb(w http.ResponseWriter, r *http.Request)

Handler function for all `RandomData`s in database

func (*DB) HandleSpecificWeb

func (db *DB) HandleSpecificWeb(w http.ResponseWriter, r *http.Request)

Handler function for a specific `RandomData` in database

func (*DB) UpdateSpecific

func (db *DB) UpdateSpecific(id uint, newRD randomdata.RandomData) error

Replace `Randomdata` in db with given id with a new one. Does not affect `DateCreated`

Jump to

Keyboard shortcuts

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