mongodb-largest-documents
A simple Node.js script that finds the top X largest documents in a given MongoDB collection.
- Scalable - can work with any collection size
- Fast - utilizes range-based pagination for fast table scanning
- Easy - simply provide the MongoDB connection string and collection name
Preview
Requirements
- A MongoDB database
- Node.js v4.x+ for ES6 generators support
Usage
First, install the package using npm:
npm install mongodb-largest-documents --save
Then, use the following code to find the top 100 largest documents in a given collection, modifying the config
variable accordingly:
var mongodbLargestDocuments = ; // Configure task herevar config = // MongoDB connection string db: 'localhost/test' // Name of collection to inspect collectionName: 'users' // Process X items every iteration batchSize: 100 // Limit output to X largest documents outputTopXLargest: 100; // Run the module;
Run the script and watch the console for progress - it will invoke your callback when it traverses the entire collection.
License
Apache 2.0