Function to find all large docs in Mongo
Allow customizing sizeLimit
@@ -224,11 +224,14 @@ var oak = (function(global){
* @param {object} options pass optional parameters for host, port, db, and filename
*/
api.dumpLargeDocIds = function (options) {
+ options = options || {};
+ var sizeLimit = options.sizeLimit || 15 * 1024 * 1024;
var count = 0;
var ids = [];
+ print("Using size limit: " + sizeLimit);
db.nodes.find().forEach(function (doc) {
var size = Object.bsonsize(doc);
- if (size > 15 * 1024 * 1024) {
+ if (size > sizeLimit) {
print("id|" + doc._id);
ids.push(doc._id)
}
@@ -243,7 +246,7 @@ var oak = (function(global){
if (ids.length > 0) {
var query = JSON.stringify({_id: {$in: ids}});
print("Using following export command to tweak the output");
- options = options || {};
+
options.db = db.getName();
print(createExportCommand(query, options));
}
