GSG-G11 / Fitness-house

a website that give the user the ability to search about Gyms suits him
https://fit-house.herokuapp.com/
4 stars 4 forks source link

Fix build database function to create data async #70

Closed AhmedQeshta closed 2 years ago

AhmedQeshta commented 2 years ago

Fix build database function to create data async

await Promise.all([
    ...users.map(async (user: any) => {
      await User.create(user);
    }),
    ...gyms.map(async (gym: any) => {
      await Gym.create(gym);
    }),
  ]);
  await Promise.all([
    ...images.map(async (image: any) => {
      await Image.create(image);
    }),
    ...subscription.map(async (sub: any) => {
      await Subscription.create(sub);
    }),
    ...reviews.map(async (review: any) => {
      await Review.create(review);
    }),
  ]);

And remove subscriptions and reviews and images to another Promise.all block, to make sure to create them after creating users and gyms