postgres

package
v0.0.0-...-f40e6d9 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertRepository

type AlertRepository struct {
	DB *sql.DB
}

AlertRepository is a postgres implementation of the AlertRepository interface

func (AlertRepository) CreateAlert

func (repo AlertRepository) CreateAlert(alert easyalert.Alert) (easyalert.Alert, error)

CreateAlert creates a new alert in the Postgres database and returns it with ID and created_at/updated_at filled.

func (AlertRepository) DeleteAlert

func (repo AlertRepository) DeleteAlert(alert easyalert.Alert) error

DeleteAlert deletes the alert given as a parameter by using the ID.

func (AlertRepository) FindAlert

func (repo AlertRepository) FindAlert(query string, params ...interface{}) (easyalert.Alert, error)

FindAlert fetches an alert using the query passed as a string and returns it. If the alert does not exist it will return easyalert.ErrRecordDoesNotExist.

func (AlertRepository) FindAlerts

func (repo AlertRepository) FindAlerts(query string, params ...interface{}) ([]easyalert.Alert, error)

FindAlerts fetches all alerts based on the query and returns them.

func (AlertRepository) UpdateAlert

func (repo AlertRepository) UpdateAlert(alert easyalert.Alert) (easyalert.Alert, error)

UpdateAlert updates an existing alert in the Postgres database and returns it with updated_at updated.

type UserRepository

type UserRepository struct {
	DB *sql.DB
}

UserRepository is a postgres implementation of the UserRepository interface

func (UserRepository) CreateUser

func (repo UserRepository) CreateUser(user easyalert.User) (easyalert.User, error)

CreateUser creates a user in the Postgres database and returns it with ID and created_at/updated_at filled.

func (UserRepository) DeleteUser

func (repo UserRepository) DeleteUser(user easyalert.User) error

DeleteUser deletes a user and returns an error if one occurs.

func (UserRepository) FindUser

func (repo UserRepository) FindUser(query string, params ...interface{}) (easyalert.User, error)

FindUser fetches a user by ID and returns it. If the user does not exist it will return easyalert.ErrRecordDoesNotExist.

func (UserRepository) FindUsers

func (repo UserRepository) FindUsers() ([]easyalert.User, error)

FindUsers fetches all users and returns them.

func (UserRepository) UpdateUser

func (repo UserRepository) UpdateUser(user easyalert.User) (easyalert.User, error)

UpdateUser updates all fields of the user in the Postgres database and returns it with updated_at refreshed.

Jump to

Keyboard shortcuts

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