MongoDB and Mongoose - Create Many Records with model.create()

Tell us what’s happening:
Describe your issue in detail here.
I keep running into an error that collection.remove is depracted. Here is the code i have for the create many people function :
const createManyPeople = (arrayOfPeople, done) => {

var arrayOfPeople = [{name:‘Merissa’, age:23, favoriteFoods: [‘Strawberries’]}, {name:‘Audrey’, age: 20, favoriteFoods: [‘Salad’]}, {name: ‘Wendy’, age: 42, favoriteFoods: [‘wine’, ‘burgers’]}
// create people objects at once
var createPeople = function(arrayOfPeople, done){
Person.create(arrayOfPeople, function(err, people){
if (err) console.log(err)
done(null, people)

any idea on how to use the other delete method instead?

Your project link(s)

solution: fcc-challenge3 - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36

Challenge: MongoDB and Mongoose - Create Many Records with model.create()

Link to the challenge:

im confused :sweat_smile:
your title says create, and also ur code
but u asking about delete??

if create gives u error… probably cuz it dont accept that kind of values/arguments
i would go and check the documentation

IF u wanna use create method with an array… then u would need to iterate the array and pass one by one each element to that method

on the other hand… IF u wanna pass the whole array to create all those documents at once… then u will need to use ANOTHER method insertMany according to the documentation

create accepts an array as parameter

You can ignore the deprecation warning it just means in future versions of the library it may be removed. It’s basically just to give the developer a head start to change code as needed for use with future versions of the library.

arrayOfPeople is passed to the createManyPeople function for you. You then pass it to the Person.create() method as the first argument before the callback (remember to do the done song and dance inside the callback).

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.