Add PostgreSQL database option and more booking flow functionalities

This commit is contained in:
2023-05-08 01:29:59 +02:00
parent d8346a20be
commit e2e6759dc0
40 changed files with 1594 additions and 907 deletions

View File

@@ -16,14 +16,16 @@ type Storage interface {
CreateBooking(internal.Booking) error
GetBooking(id string) (*internal.Booking, error)
GetUserBookings(userid string) ([]internal.Booking, error)
UpdateBookingStatus(bookingid string, status string) error
// Caching temporary results
PersistedKVPut(documents []any) error
PersistedKVGet(id string, document any) error
StoreSearchResults([]internal.SearchResult) error
GetSearchResult(id string) (*internal.SearchResult, error)
// PersistedKVPut(documents []any) error
// PersistedKVGet(id string, document any) error
StoreRouteSchedules([]internal.PlannedRouteSchedule) error
GetRouteSchedule(id string) (*internal.PlannedRouteSchedule, error)
Migrate() error
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
@@ -35,6 +37,9 @@ func NewStorage(cfg *viper.Viper) (Storage, error) {
case "mongodb":
s, err := NewMongoDBStorage(cfg)
return s, err
case "psql":
s, err := NewPostgresqlStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}