How to save an array of objects to mongoose DB with only one call?

后端 未结 5 1699
野的像风
野的像风 2020-12-29 07:34

Is there any way to save an array of JSON object to a mongodb with only one call? something like:

schemeObject.save(array_of_json_object, ca         


        
5条回答
  •  北海茫月
    2020-12-29 07:57

    This works with mongoose as well

    Laptop.insertMany(laptopData, function (err, laptop) {
      if (err) {
        console.log(err);
      };
      console.log(laptop);
    });
    

提交回复
热议问题