diff options
author | James Wahlin <james.wahlin@10gen.com> | 2015-09-30 17:41:56 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2015-10-07 15:42:22 -0400 |
commit | ec97a61067e2dc3f9c4e58a9d66b5e1f2600f978 (patch) | |
tree | 40c67ec652a87b17b794a8ba5fc5aa3b4fc3e99e /jstests/core/index_stats.js | |
parent | 33167b814bb9d8962205a85fed34c9d88942db83 (diff) | |
download | mongo-ec97a61067e2dc3f9c4e58a9d66b5e1f2600f978.tar.gz |
SERVER-20520 Include index key in $indexStats return documents
Diffstat (limited to 'jstests/core/index_stats.js')
-rw-r--r-- | jstests/core/index_stats.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/jstests/core/index_stats.js b/jstests/core/index_stats.js index f2f913b3235..1fc028fca31 100644 --- a/jstests/core/index_stats.js +++ b/jstests/core/index_stats.js @@ -17,6 +17,19 @@ return undefined; } + var getIndexKey = function (indexName) { + var cursor = col.aggregate([{$indexStats: {}}]); + while (cursor.hasNext()) { + var doc = cursor.next(); + + if (doc.name === indexName) { + return doc.key; + } + } + + return undefined; + } + assert.writeOK(col.insert({a: 1, b: 1, c: 1})); assert.writeOK(col.insert({a: 2, b: 2, c: 2})); assert.writeOK(col.insert({a: 3, b: 3, c: 3})); @@ -33,6 +46,7 @@ // Confirm a stats object exists post index creation (with 0 count). assert.eq(countA, getUsageCount("a_1")); + assert.eq({a: 1}, getIndexKey("a_1")); // Confirm index stats tick on find(). col.findOne({a: 1}); |