Create Many Records - Timeout error

I’ve managed to populate the Db, but I’m getting a timeout error in FCC.
I’m guessing it’s related to the final callback, I myself don’t feel comfortable on how it’s coded.
But I can’t figure it out. I’ve read most posts here and in SO, but I don’t see it.

This is the code that creates the documents but generates timeout-

Person.create([
    new Person({        
      name: 'Pepe',
      age: 15,
      favoriteFoods: ["Pizza", "Broccoli", "Cheese", "Bread"]
      }),
    new Person({
      name: 'Bob',
      age: 75,
      favoriteFoods: ["Tomatoes", "Lentils"]
      }),
    new Person({
      name: 'Carl',
      age: 95,
      favoriteFoods: ["Chips", "Chorizo"]
      })
    ], function (err, data) {
    if (err) console.log(err);
  });

Hi gdgauthier,
I’m new at this as well, but I think the function argument “arrayOfPeople” is the array with all the individual Person model information in it. Try feeding that in instead of manually creating an array yourself. Hope this helps. :sunglasses:

1 Like

Thank you, Raphael. Your post made me realize that I was miss-understanding the instructions.
I’m passing the project’s array now (arrayOfPeople), and it still populates, but I get the same timeout error.

Is your function calling done()?

That did it.
Thank you my friend!

1 Like