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.
Mongo can easily handle billions of documents and can have billions of documents in the one collection but remember that the maximum document size is 16mb. There are many folk with billions of documents in MongoDB and there's lots of discussions about it on the MongoDB Google User Group.
The maximum size an individual document can be in MongoDB is 16MB with a nested depth of 100 levels. Edit: There is no max size for an individual MongoDB database.
Unless you create a capped collection, there is no limit to the number of documents in a collection. There is a 16MB limit to the size of a document (use gridfs in this situation) and limits in the storage engine for the size of the database and data.
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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With