1.0.5 • Published 8 years ago

mongodb-largest-documents v1.0.5

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
8 years ago

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

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago