postgres

package
v0.0.0-...-cc73b8b Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetMainStorage

func SetMainStorage(storage *Storage)

SetMainStorage will a single-instance storage globally

Types

type Storage

type Storage struct {
	Pool     *pgx.ConnPool
	Resource string
}

Storage is a struct that holds important database info like the connection pool and resource in use used

var DB *Storage

DB is a singleton instance of the Storage

func New

func New(resource string) (Storage, error)

New will generate a Storage containing a pool of connections for a given resource type

func (*Storage) Delete

func (storage *Storage) Delete(resource, id string) error

Delete will make a DELETE query to the database given a resource and an id

func (*Storage) Load

func (storage *Storage) Load(resource, id string) (result string, notFound bool, e error)

Load will make a SELECT query to a database given a resource an id

func (*Storage) Save

func (storage *Storage) Save(resource, id, data string) error

Save will make a INSERT query to the database given a resource and an id

Jump to

Keyboard shortcuts

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