Mongoose RangeError:超出最大调用堆栈大小

时间:2016-08-08 07:12:21

标签: node.js mongodb mongoose

我使用Mongoose作为MongoDB ODM。目前我在使用某些标准获取文档时遇到问题 - Mongoose抛出 RangeError:超出最大调用堆栈大小

我正在查询1500多个文档,这些文档有自定义子文档。

这是代码:

  Customer.find({
      customerNonActiveBit: false,
      customerType: 0,
      customerBit: true
    })
    .where({priceLists: { $not: {$size: 0}}, customerContacts: { $not: {$size: 0}}})
    .exec()
    .then(customers => res.send(customers))
    .catch(err => {
      logger.error('Error while getting customers', err);
      res.sendStatus(500);
    });

以下是客户架构:

var customerSchema = new Schema({
  name1: String,
  name2: String,
  customerId: { type: Number, required: true, unique: true },
  customerNonActiveBit: Boolean,
  customerType: Number,
  customerBit: Boolean,
  customerContacts: [{
    contactId: Number,
    name: String,
    email: String,
    number: String,
    sendPriceList: Boolean
  }],
  priceLists: [{type: mongoose.Schema.Types.ObjectId, ref: 'PriceList'}]
});

我找到了一些问题的答案,但我的情况略有不同。

0 个答案:

没有答案