Get all bookings
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 44s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 44s
This commit is contained in:
@@ -280,6 +280,29 @@ func (s MongoDBStorage) GetUserBookings(userid string) ([]internal.Booking, erro
|
||||
return bookings, nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) GetAllBookings() ([]internal.Booking, error) {
|
||||
findOptions := options.Find()
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"])
|
||||
cur, err := collection.Find(context.TODO(), bson.M{}, findOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var bookings []internal.Booking
|
||||
for cur.Next(context.TODO()) {
|
||||
var elem internal.Booking
|
||||
|
||||
if err := cur.Decode(&elem); err != nil {
|
||||
log.Error().Err(err).Msg("error reading bookings response")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bookings = append(bookings, elem)
|
||||
}
|
||||
|
||||
return bookings, nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) UpdateBookingStatus(bookingid string, status string) error {
|
||||
// TODO implement UpdateBookingStatus
|
||||
return errors.New("MongoDB Storage - UpdateBookingStatus not implemented")
|
||||
|
||||
Reference in New Issue
Block a user