db

package
v0.0.0-...-7fb4172 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQueryTimedOut       = errors.New("query timed out")
	ErrDatabaseError       = errors.New("could not access data store")
	ErrSwipeRequestInvalid = errors.New("failed to swipe on profile")
	ErrNoValidSession      = errors.New("no valid session")
	ErrLoginFailed         = errors.New("could not log in")
)

Functions

This section is empty.

Types

type DiscoverFilters

type DiscoverFilters struct {
	MinAge  int
	MaxAge  int
	Genders []string
}

type DiscoverProfile

type DiscoverProfile struct {
	Id             int32   `json:"id"`
	Age            int     `json:"age"`
	Name           string  `json:"name"`
	Gender         string  `json:"gender"`
	DistanceFromMe int     `json:"distanceFromMe"`
	Lat            float64 `json:"-"`
	Long           float64 `json:"-"`
}

type Location

type Location struct {
	Lat  float64
	Long float64
}

type Match

type Match struct {
	Id int
}

type PostgresStore

type PostgresStore struct {
	PostgresConnection *pgx.ConnPool
}

Store provides access to the database.

func NewPostgresStore

func NewPostgresStore(connStr string) (*PostgresStore, error)

NewStore sets up a new database store.

func (*PostgresStore) CreateProfile

func (ps *PostgresStore) CreateProfile(ctx context.Context, age int, name string, gender string, email string, password string, location Location) (*Profile, error)

func (*PostgresStore) GetDiscoverProfiles

func (ps *PostgresStore) GetDiscoverProfiles(ctx context.Context, id int32, filters DiscoverFilters) ([]*DiscoverProfile, error)

func (*PostgresStore) GetSession

func (ps *PostgresStore) GetSession(ctx context.Context, token string) (int32, error)

func (*PostgresStore) Login

func (ps *PostgresStore) Login(ctx context.Context, email string, password string) (string, error)

func (*PostgresStore) Swipe

func (ps *PostgresStore) Swipe(ctx context.Context, userId int32, swipedUserId int32, liked bool) (bool, int, error)

func (*PostgresStore) TestConnection

func (s *PostgresStore) TestConnection(ctx context.Context) error

TestConnection tests that the Store can properly connect to the Postgres Server.

type Profile

type Profile struct {
	Id       int32
	Age      int
	Name     string
	Gender   string
	Email    string
	Password string
	Location Location
}

Checkout describes a checkout as stored in the db.

type ProfileStore

type ProfileStore interface {
	CreateProfile(context.Context, int, string, string, string, string, Location) (*Profile, error)
	GetDiscoverProfiles(context.Context, int32, DiscoverFilters) ([]*DiscoverProfile, error)
	GetSession(context.Context, string) (int32, error)
	Login(context.Context, string, string) (string, error)
	Swipe(context.Context, int32, int32, bool) (bool, int, error)
}

ProfileStore describes an interface which any data store must implement to achieve required functionality

type Session

type Session struct {
	Token     string
	UserId    int32
	Timestamp time.Time
}

type SwipeDetails

type SwipeDetails struct {
	Id          int32
	SwipedOn    []int32
	SwipedYesBy []int32
}

Jump to

Keyboard shortcuts

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