pg

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 15 Imported by: 0

README

PostgreSQL Database Handler

This part needs bin-data:

go get -u github.com/go-bindata/go-bindata/...

To generate migrations install migrate using the tutorial at https://github.com/golang-migrate/migrate/tree/master/cmd/migrate

Then:

migrate create -ext sql -dir migrations -seq name_of_migration

It will be added automagically with go-generate to bindata

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgreSQLDBDriver

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

PostgreSQLDBDriver is a database driver for PostgreSQL

func MakePostgreSQLDBDriver

func MakePostgreSQLDBDriver(log slog.Instance) *PostgreSQLDBDriver

MakeRethinkDBDriver creates a new database driver for rethinkdb

func (*PostgreSQLDBDriver) AddGPGKey

func (h *PostgreSQLDBDriver) AddGPGKey(key models.GPGKey) (string, bool, error)

AddGPGKey adds a GPG Key to the database or update an existing one by fingerprint Returns generated id / hasBeenAdded / error

func (*PostgreSQLDBDriver) AddGPGKeys

func (h *PostgreSQLDBDriver) AddGPGKeys(keys []models.GPGKey) (ids []string, addeds []bool, err error)

AddGPGKey adds a list GPG Key to the database or update an existing one by fingerprint Same as AddGPGKey but in a single transaction

func (*PostgreSQLDBDriver) AddUser

func (h *PostgreSQLDBDriver) AddUser(um models.User) (string, error)

AddUser adds a user in the database if not exists

func (*PostgreSQLDBDriver) AddUserToken

func (h *PostgreSQLDBDriver) AddUserToken(ut models.UserToken) (string, error)

func (*PostgreSQLDBDriver) Connect

func (h *PostgreSQLDBDriver) Connect(connectionString string) error

func (*PostgreSQLDBDriver) DeleteGPGKey

func (h *PostgreSQLDBDriver) DeleteGPGKey(key models.GPGKey) error

DeleteGPGKey deletes the specified GPG key by using it's ID

func (*PostgreSQLDBDriver) FetchGPGKeyByFingerprint

func (h *PostgreSQLDBDriver) FetchGPGKeyByFingerprint(fingerprint string) (*models.GPGKey, error)

FetchGPGKeyByFingerprint fetch a GPG Key by its fingerprint

func (*PostgreSQLDBDriver) FetchGPGKeysWithoutSubKeys

func (h *PostgreSQLDBDriver) FetchGPGKeysWithoutSubKeys() (res []models.GPGKey, err error)

FetchGPGKeysWithoutSubKeys fetch all keys that does not have a subkey This query is not implemented on PostgreSQL

func (*PostgreSQLDBDriver) FindGPGKeyByEmail

func (h *PostgreSQLDBDriver) FindGPGKeyByEmail(email string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByEmail find all keys that has a underlying UID that contains that email

func (*PostgreSQLDBDriver) FindGPGKeyByFingerPrint

func (h *PostgreSQLDBDriver) FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByFingerPrint find all keys that has a fingerprint that matches the specified fingerprint

func (*PostgreSQLDBDriver) FindGPGKeyByName

func (h *PostgreSQLDBDriver) FindGPGKeyByName(name string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByName find all keys that has a underlying UID that contains that name

func (*PostgreSQLDBDriver) FindGPGKeyByValue

func (h *PostgreSQLDBDriver) FindGPGKeyByValue(value string, pageStart, pageEnd int) ([]models.GPGKey, error)

FindGPGKeyByValue find all keys that has a underlying UID that contains that email, name or fingerprint specified by value

func (*PostgreSQLDBDriver) FinishCursor

func (h *PostgreSQLDBDriver) FinishCursor() error

func (*PostgreSQLDBDriver) GetUser

func (h *PostgreSQLDBDriver) GetUser(username string) (um *models.User, err error)

GetUser fetchs a user from the database by it's username

func (*PostgreSQLDBDriver) GetUserToken

func (h *PostgreSQLDBDriver) GetUserToken(token string) (ut *models.UserToken, err error)

func (*PostgreSQLDBDriver) HealthCheck

func (h *PostgreSQLDBDriver) HealthCheck() error

HealthCheck returns nil if everything is OK with the handler

func (*PostgreSQLDBDriver) InitCursor

func (h *PostgreSQLDBDriver) InitCursor() error

func (*PostgreSQLDBDriver) InvalidateUserTokens

func (h *PostgreSQLDBDriver) InvalidateUserTokens() (int, error)

func (*PostgreSQLDBDriver) NextGPGKey

func (h *PostgreSQLDBDriver) NextGPGKey(key *models.GPGKey) bool

func (*PostgreSQLDBDriver) NextUser

func (h *PostgreSQLDBDriver) NextUser(user *models.User) bool

func (*PostgreSQLDBDriver) NumGPGKeys

func (h *PostgreSQLDBDriver) NumGPGKeys() (int, error)

func (*PostgreSQLDBDriver) RemoveUserToken

func (h *PostgreSQLDBDriver) RemoveUserToken(token string) (err error)

RemoveUserToken removes a user token from the database

func (*PostgreSQLDBDriver) UpdateGPGKey

func (h *PostgreSQLDBDriver) UpdateGPGKey(key models.GPGKey) (err error)

UpdateGPGKey updates the specified GPG key by using it's ID

func (*PostgreSQLDBDriver) UpdateUser

func (h *PostgreSQLDBDriver) UpdateUser(um models.User) error

UpdateUser updates user fingerprint, password and / or fullname by it's ID

Directories

Path Synopsis
Code generated for package migrations by go-bindata DO NOT EDIT.
Code generated for package migrations by go-bindata DO NOT EDIT.

Jump to

Keyboard shortcuts

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