最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why mongodb not giving me more than 100 documents? - Stack Overflow

programmeradmin1浏览0评论

Why does my query not working with more than 100 documents in collection?

db.collection('allowedmacs').find().toArray(function(err, docs) {
console.log(docs);
}

err says this:

name: 'MongoError',
message: 'connection destroyed, not possible to instantiate cursor'

If documents <100 all works fine.

Why does my query not working with more than 100 documents in collection?

db.collection('allowedmacs').find().toArray(function(err, docs) {
console.log(docs);
}

err says this:

name: 'MongoError',
message: 'connection destroyed, not possible to instantiate cursor'

If documents <100 all works fine.

Share Improve this question edited Jan 23, 2017 at 11:28 AdrieanKhisbe 4,0588 gold badges39 silver badges45 bronze badges asked Sep 16, 2016 at 15:35 Nikita MassalitinNikita Massalitin 831 silver badge4 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 23

You're probably doing something like this:

db.collection('allowedmacs').find().toArray(function(err, docs) {
  console.log(docs);
});
db.close();

So you're closing the database before the callback to toArray has been called (although it may work on some occassions).

Instead, try this:

db.collection('allowedmacs').find().toArray(function(err, docs) {
  console.log(docs);
  db.close();
});

in source there is written:

MongoDB supports no more than 100 levels of nesting for BSON documents.

maybe you look into : Mongo and find always limited to 100 with geo data

发布评论

评论列表(0)

  1. 暂无评论