Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions hotelReservation/cmd/attractions/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("attractions-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared attractions-db")

collectionH := client.Database("attractions-db").Collection("hotels")
_, err = collectionH.InsertMany(context.TODO(), newPoints)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/geo/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("geo-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared geo-db")

collection := client.Database("geo-db").Collection("geo")
_, err = collection.InsertMany(context.TODO(), newPoints)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/profile/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("profile-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared profile-db")

collection := client.Database("profile-db").Collection("hotels")
_, err = collection.InsertMany(context.TODO(), newProfiles)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/rate/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("rate-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared rate-db")

collection := client.Database("rate-db").Collection("inventory")
_, err = collection.InsertMany(context.TODO(), newRatePlans)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/recommendation/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("recommendation-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared recommendation-db")

collection := client.Database("recommendation-db").Collection("recommendation")
_, err = collection.InsertMany(context.TODO(), newHotels)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/reservation/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("reservation-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared reservation-db")

database := client.Database("reservation-db")
resCollection := database.Collection("reservation")
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/review/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("review-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared review-db")

collection := client.Database("review-db").Collection("reviews")
_, err = collection.InsertMany(context.TODO(), newReviews)
Expand Down
5 changes: 5 additions & 0 deletions hotelReservation/cmd/user/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func initializeDatabase(url string) (*mongo.Client, func()) {
log.Panic().Msg(err.Error())
}
log.Info().Msg("Successfully connected to MongoDB")
db := client.Database("user-db")
if err := db.Drop(context.TODO()); err != nil {
log.Fatal().Msg(err.Error())
}
log.Info().Msg("Successfully cleared user-db")

collection := client.Database("user-db").Collection("user")
_, err = collection.InsertMany(context.TODO(), newUsers)
Expand Down