diff options
author | Tyler Brock <tyler.brock@gmail.com> | 2014-12-15 11:27:03 -0500 |
---|---|---|
committer | Tyler Brock <tyler.brock@gmail.com> | 2014-12-16 14:36:30 -0500 |
commit | de16932890952898881673fdd76c5f45d6dc49e1 (patch) | |
tree | 87afa887b4fdbefb0e4afd5afc08bffc62e3554f /src/mongo/db/commands | |
parent | 0aede468dc2ea475aa83bddd8be1e56a19ca6a3a (diff) | |
download | mongo-de16932890952898881673fdd76c5f45d6dc49e1.tar.gz |
SERVER-16518 listIndexes response changed to cursor object form
As a temporary compatibility measure, the legacy behavior is preserved
if the "cursor" option is not sent with the command. This
compatibility layer will be removed as part of work for the parent
ticket.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/list_indexes.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index 638f3bebe9e..3403ede8b1e 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -112,12 +112,26 @@ namespace mongo { vector<string> indexNames; cce->getAllIndexes( txn, &indexNames ); + // TODO: Handle options specified in the command request object under the "cursor" + // field. + + // TODO: If the full result set does not fit in one batch, allocate a cursor to store + // the remainder of the results. + BSONArrayBuilder arr; for ( size_t i = 0; i < indexNames.size(); i++ ) { arr.append( cce->getIndexSpec( txn, indexNames[i] ) ); } - result.append( "indexes", arr.arr() ); + if ( cmdObj["cursor"].type() == mongo::Object ) { + const long long cursorId = 0LL; + std::string cursorNamespace = str::stream() + << dbname << ".$cmd." << name << "." << ns.coll(); + Command::appendCursorResponseObject( cursorId, cursorNamespace, arr.arr(), + &result ); + } else { + result.append( "indexes", arr.arr() ); + } return true; } |