postgres

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgres implements an SQL Database for Postgres servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Setup initializes the database by reading the files.
	Setup(ctx context.Context, files []io.Reader) error
	// Query reads from the database without updating it.
	Query(ctx context.Context, q sql.Query, dest ...interface{}) error
	// Exec makes a change to existing data, creating/modifying/removing it.
	Exec(ctx context.Context, queries ...sql.Query) error
}

Database contains methods to create, read, update, and delete data.

type UserBackend

type UserBackend struct {
	Database
}

UserBackend provides functions to manages users on a Postgres SQL Database.

func (*UserBackend) Create

func (ub *UserBackend) Create(ctx context.Context, u user.User) error

Create adds the username/password pair.

func (*UserBackend) Delete

func (p *UserBackend) Delete(ctx context.Context, u user.User) error

Delete removes the user.

func (*UserBackend) Read

func (ub *UserBackend) Read(ctx context.Context, u user.User) (*user.User, error)

Get queries the database for the user by username

func (*UserBackend) UpdatePassword

func (ub *UserBackend) UpdatePassword(ctx context.Context, u user.User) error

UpdatePassword updates the password for user identified by the username.

func (*UserBackend) UpdatePointsIncrement

func (ub *UserBackend) UpdatePointsIncrement(ctx context.Context, usernamePoints map[string]int) error

UpdatePointsIncrement increments the points for all of the usernames.

Jump to

Keyboard shortcuts

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