initial commit
This commit is contained in:
40
storage/storage.go
Normal file
40
storage/storage.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/solidarity-transport/types"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
CreateDriverRegularAvailability(types.DriverRegularAvailability) error
|
||||
CreateDriverRegularAvailabilities([]*types.DriverRegularAvailability) error
|
||||
DeleteDriverRegularAvailability(driverid string, availabilityid string) error
|
||||
GetDriverRegularAvailability(driverid string, availabilityid string) (*types.DriverRegularAvailability, error)
|
||||
GetDriverRegularAvailabilities(driverid string) ([]*types.DriverRegularAvailability, error)
|
||||
|
||||
GetRegularAvailabilities(day int, timeInDay string) ([]*types.DriverRegularAvailability, error)
|
||||
|
||||
PushDriverJourneys([]*types.DriverJourney) error
|
||||
GetDriverJourney(id string) (*types.DriverJourney, error)
|
||||
|
||||
CreateBooking(types.Booking) error
|
||||
GetAllBookings() ([]*types.Booking, error)
|
||||
GetBooking(id string) (*types.Booking, error)
|
||||
UpdateBookingStatus(bookingid string, newStatus string) error
|
||||
}
|
||||
|
||||
func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
storage_type := cfg.GetString("storage.db.type")
|
||||
|
||||
switch storage_type {
|
||||
case "mongodb":
|
||||
return NewMongoDBStorage(cfg)
|
||||
case "memory":
|
||||
return NewMemoryStorage(cfg)
|
||||
default:
|
||||
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user