diff --git a/storage/mongodb.go b/storage/mongodb.go index af8cbff..5aecf50 100644 --- a/storage/mongodb.go +++ b/storage/mongodb.go @@ -63,7 +63,7 @@ func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error) { } func (s MongoDBStorage) CreatePassenger(passenger internal.Passenger) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["passengers"]) _, err = uuid.Parse(passenger.Passenger.ID) if err != nil { @@ -101,7 +101,7 @@ func (s MongoDBStorage) CreatePassenger(passenger internal.Passenger) (err error return nil } func (s MongoDBStorage) UpdatePassenger(passenger internal.Passenger) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["passengers"]) _, err = uuid.Parse(passenger.Passenger.ID) if err != nil { @@ -132,7 +132,7 @@ func (s MongoDBStorage) UpdatePassenger(passenger internal.Passenger) (err error } func (s MongoDBStorage) GetPassenger(passengerID string) (passenger internal.Passenger, err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["passengers"]) var preferencesJSON []byte _ , err = uuid.Parse(passenger.Passenger.ID) @@ -161,7 +161,7 @@ func (s MongoDBStorage) GetPassenger(passengerID string) (passenger internal.Pas } func (s MongoDBStorage) CreateDriver(driver internal.Driver) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["drivers"]) //var availabilities []byte _, err = uuid.Parse(driver.Driver.ID) if err != nil { @@ -235,7 +235,7 @@ func (s MongoDBStorage) CreateDriver(driver internal.Driver) (err error) { return nil } func (s MongoDBStorage) UpdateDriver(driver internal.Driver) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["groups"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["drivers"]) //var availabilities []byte _, err = uuid.Parse(driver.Driver.ID) if err != nil { @@ -305,7 +305,7 @@ func (s MongoDBStorage) UpdateDriver(driver internal.Driver) (err error) { } func (s MongoDBStorage) GetDriver(driverID string) ( *internal.Driver, error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["drivers"]) // var preferencesJSON []byte // var departureAddress []byte // var availabilitiesJSON []byte @@ -364,7 +364,7 @@ func (s MongoDBStorage) GetDriver(driverID string) ( *internal.Driver, error) { } func (s MongoDBStorage) CreateBooking(booking internal.BookingRequest) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"]) _, err = uuid.Parse(booking.Driver_id) if err != nil { log.Error().Err(err).Msg("MongoDB Storage CreateBooking invalid Driver ID") @@ -417,7 +417,7 @@ func (s MongoDBStorage) CreateBooking(booking internal.BookingRequest) (err erro } func (s MongoDBStorage) GetBooking(bookingID string) (*internal.Booking, error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"]) //var departureAddress []byte //var destinationAddress []byte booking := &internal.Booking{} @@ -460,7 +460,7 @@ func (s MongoDBStorage) GetBooking(bookingID string) (*internal.Booking, error) } func (s MongoDBStorage) UpdateBookingStatus(bookingStatusID string, status internal.BookingStatus) (err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"]) _, err = uuid.Parse(bookingStatusID) if err != nil { log.Error().Err(err).Msg("MongoDB Storage UpdateBookingStatus invalid Booking ID") @@ -480,7 +480,7 @@ func (s MongoDBStorage) UpdateBookingStatus(bookingStatusID string, status inter } func (s MongoDBStorage) FilterUserBookingsByStatus(userType string, status internal.BookingStatus, userID string) (bookings []internal.Booking, err error) { - collection := s.Client.Database(s.DbName).Collection(s.Collections["groups"]) + collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"]) if err != nil { return nil, errors.New("invalid UUID") } @@ -641,7 +641,7 @@ func (s MongoDBStorage) populateBookingDetails(booking internal.Booking, departu } func (s MongoDBStorage) GetAllDrivers( date int64) (drivers []internal.Driver, err error) { - // rows := s.Client.Database(s.DbName).Collection(s.Collections["users"]) + // rows := s.Client.Database(s.DbName).Collection(s.Collections["drivers"]) if err != nil { return nil, err }