猫鼬Model.create()函数不会保存所有值

时间:2019-04-07 00:45:53

标签: node.js mongodb mongoose

我正在尝试将一系列文档保存到MongoDb Atlas Cloud集群中,但并非所有文档都已保存。该数组有14000个文档,其文档架构如下所示。我目前在免费的MongoDb Atlas集群上,所以我的第一个猜测是它没有足够的处理能力来保存所有文档,直到超时?

.then中的console.log或.catch均未在.create调用中触发。我已从mongo中删除了该收藏集,并使用保存的不同数量的文档再次运行了该收藏集。

//The schema file 

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const IngredientsSchema = new Schema({
  description: {
    type: String,
    required: true
  },
  term: {
    type: String,
    required: true
  },
  searchValue: {
    type: String,
    required: true
  }
});

const Ingredients = mongoose.model('Ingredients', IngredientsSchema, 'Ingredients');

module.exports = Ingredients;

//From the controller making the db call

Ingredients.create(arrayOfDocs)
    .then(dbArr => {
        console.log(`ingredients metadata added to database`)
    })
    .catch(err => {
        console.log(err);
    })

这是我使用mongodb和Mongo Atlas服务的第一个项目。任何帮助将不胜感激。

0 个答案:

没有答案
相关问题