Skip to content

Commit

Permalink
INT-1660: Fix TypeError: Cannot read property 'indexSizes' of undefin…
Browse files Browse the repository at this point in the history
…ed (#36)
  • Loading branch information
imlucas committed Aug 4, 2016
1 parent 9c0f805 commit 9b2613b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/index-model/lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var async = require('async');
var mongodbNS = require('mongodb-ns');
var isNotAuthorizedError = require('mongodb-js-errors').isNotAuthorized;

// var debug = require('debug')('mongodb-index-model:fetch');
var debug = require('debug')('mongodb-index-model:fetch');

/**
* helper function to attach objects to the async.auto task structure.
Expand Down Expand Up @@ -88,8 +88,13 @@ function getIndexSizes(done, results) {
var ns = mongodbNS(results.namespace);
db.db(ns.database).collection(ns.collection).stats(function(err, res) {
if (err) {
done(err);
if (isNotAuthorizedError(err)) {
debug('Not authorized to get collection stats. Returning default for indexSizes {}.');
return done(null, {});
}
return done(err);
}

res = _.mapValues(res.indexSizes, function(size) {
return {size: size};
});
Expand Down

0 comments on commit 9b2613b

Please sign in to comment.