psql

package
v0.0.0-...-9da9030 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package psql used for storing data in PostgreSQL database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(cfg Config) (*sql.DB, error)

NewDB creates and validates new db connection

Types

type Config

type Config struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
	SSLMode  string
	Logger   *zap.Logger
}

Config represents all required fields for connecting to postgres db

func (Config) String

func (cfg Config) String() string

String returns connection string from config

type Launchpad

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

Launchpad represents repository for launchpad entity

func NewLaunchpad

func NewLaunchpad(db *sql.DB) *Launchpad

NewLaunchpad return instance of launchpad repository

func (*Launchpad) AddReservation

func (r *Launchpad) AddReservation(launchpadID, date string) error

AddReservation adds reservation of requested launchpad to db

func (*Launchpad) GetForDate

func (r *Launchpad) GetForDate(launchpadID string, date time.Time) (core.Launchpad, error)

GetForDate fetches data from DB about launchpad for requested date

type Order

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

Order represents repository for orders entity

func NewOrder

func NewOrder(db *sql.DB) *Order

NewOrder return instance of order repository

func (*Order) Create

func (r *Order) Create(userID string, data *dto.Order) (string, error)

CreateOrder creates new order

func (*Order) GetAll

func (r *Order) GetAll() ([]*core.Order, error)

GetAllOrders returns all orders from DB

func (*Order) GetByID

func (r *Order) GetByID(orderID string) (core.Order, error)

GetOrderByID returns order by ID

func (*Order) RemoveByID

func (r *Order) RemoveByID(orderID string) error

GetOrderByID returns order by ID

type Storage

type Storage struct {
	Launchpad *Launchpad
	Order     *Order
	Trip      *Trip
	User      *User
}

Storage contains all implemented repositories

func NewStorage

func NewStorage(db *sql.DB) *Storage

NewStorage returns all implemented repositories

type Trip

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

Trip represents repository for trips entity

func NewTrip

func NewTrip(db *sql.DB) *Trip

NewTrip return instance of trip repository

func (*Trip) GetByDestination

func (r *Trip) GetByDestination(destinationID string) (core.Trip, error)

GetByDestination returns trip entity mapped to the trips schedule

type User

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

User represents repository for users entity

func NewUser

func NewUser(db *sql.DB) *User

NewUser return instance of user repository

func (*User) FindOrCreate

func (r *User) FindOrCreate(data *dto.User) (core.User, error)

FindOrCreate returns user from DB and creates it if user doesn't exist

Jump to

Keyboard shortcuts

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