database

package
v0.0.0-...-10a4253 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

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

Postgres wraps the db connection to a postgres instance

func NewPostgres

func NewPostgres(user, password, host, database string) (*Postgres, error)

NewPostgres returns a new instance of `Postgres` with a connection to the postgres db based on provided parameters.

func (*Postgres) CreateProject

func (p *Postgres) CreateProject(projectName string, data []byte) error

CreateProject creates a new project with a JSON tree

func (*Postgres) CreateProjectKey

func (p *Postgres) CreateProjectKey(projectName string, data []byte, keys ...string) error

CreateProjectKey saves the data at the provided key path. Fails if the key already exists.

func (*Postgres) DeleteProject

func (p *Postgres) DeleteProject(projectName string) error

DeleteProject permanently deletes an entire project's tree

func (*Postgres) DeleteProjectKey

func (p *Postgres) DeleteProjectKey(projectName string, keys ...string) error

DeleteProjectKey permanently removes the data at the key path.

func (*Postgres) GetProjectKey

func (p *Postgres) GetProjectKey(projectName string, keys ...string) ([]byte, error)

GetProjectKey retrieves the object at the key path

func (*Postgres) TranslateError

func (p *Postgres) TranslateError(err error) *TranslatedError

TranslateError translates the database specific error to a simple `error` to return to the user.

func (*Postgres) UpdateProjectKey

func (p *Postgres) UpdateProjectKey(projectName string, data []byte, keys ...string) error

UpdateProjectKey updates the data at the key path. Creates a new key if it does not already exist.

type TranslatedError

type TranslatedError struct {
	Code int
	Err  error
}

TranslatedError is a database error translated with HTTP Status code

func NewTranslatedError

func NewTranslatedError(code int, err error) *TranslatedError

NewTranslatedError returns a pointer to a new `TranslatedError`

func (*TranslatedError) Error

func (t *TranslatedError) Error() string

Jump to

Keyboard shortcuts

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