mld

mongodb-largest-documents

A simple Node.js script that finds the top X largest documents in a given MongoDB collection.

Showing:

Popularity

Downloads/wk

2

GitHub Stars

4

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

5

License

Apache-2.0

Type Definitions

Tree-Shakeable

No?

Categories

Readme

mongodb-largest-documents

npm version

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

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 = require('mongodb-largest-documents');

// Configure task here
var 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
mongodbLargestDocuments(config, function (err, result) {
    // Handle errors
    if (err) {
        return console.log(err);
    }
    
    // Print largest documents to console
    console.log('Largest documents:', result);
});

Run the script and watch the console for progress - it will invoke your callback when it traverses the entire collection.

License

Apache 2.0

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial