postgres

package
v0.0.0-...-5cf43a9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package postgres provides postgres realization of interfaces.Authorizator interface

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongAffectedRows occures if some request affects on unexpected number of rows
	ErrWrongAffectedRows = errors.New("unexpected number of rows affected")
	// ErrModificationResult occures when request of modification produses strange result
	ErrModificationResult = errors.New("data changing produsec strange result")
)

Functions

This section is empty.

Types

type Authorizator

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

Authorizator implements interfaces.Authorizator interface

func NewPgx

func NewPgx(conData *ConnectionData) (*Authorizator, error)

NewPgx constructs new Authorizator with underlying pgx interface.

func NewWithDB

func NewWithDB(db *sql.DB) *Authorizator

NewWithDB constructs new Authorizator This approach provided for testing purpose

func (*Authorizator) Authorize

func (authorizator *Authorizator) Authorize(requisites *interfaces.Requisites) (id int, err error)

Authorize attempts to authorize a user and returns the id if success

func (*Authorizator) ChangeRequisites

func (authorizator *Authorizator) ChangeRequisites(requisitesOld, requisitesNew *interfaces.Requisites) (err error)

ChangeRequisites changes requisites of user from requisitesOld to requisitesNew

func (*Authorizator) Close

func (authorizator *Authorizator) Close() error

Close closes underlying database connection - not nececcary

func (*Authorizator) Register

func (authorizator *Authorizator) Register(requisites *interfaces.Requisites) (err error)

Register attempts to register a new user and returns the id if success

func (*Authorizator) Remove

func (authorizator *Authorizator) Remove(requisites *interfaces.Requisites) (err error)

Remove attempts to remove a user and returns the id if success

type ConnectionData

type ConnectionData struct {
	Host     string
	Port     int
	DBname   string
	User     string
	Password string
}

ConnectionData struct stores all database requisites

Jump to

Keyboard shortcuts

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