@@ -289,7 +289,23 @@ def collections_info(coll_name=nil)
289289 if @client . wire_version_feature? ( Mongo ::MongoClient ::MONGODB_2_8 )
290290 cmd = BSON ::OrderedHash [ :listCollections , 1 ]
291291 cmd . merge! ( :filter => { :name => coll_name } ) if coll_name
292- self . command ( cmd ) [ 'collections' ]
292+ result = self . command ( cmd , :cursor => { } )
293+ if result . key? ( 'cursor' )
294+ cursor_info = result [ 'cursor' ]
295+ pinned_pool = @connection . pinned_pool
296+ pinned_pool = pinned_pool [ :pool ] if pinned_pool . respond_to? ( :keys )
297+
298+ seed = {
299+ :cursor_id => cursor_info [ 'id' ] ,
300+ :first_batch => cursor_info [ 'firstBatch' ] ,
301+ :pool => pinned_pool ,
302+ :ns => cursor_info [ 'ns' ]
303+ }
304+
305+ Cursor . new ( self , seed . merge! ( opts ) ) . collect { |doc | doc [ 'collections' ] }
306+ else
307+ result [ 'collections' ]
308+ end
293309 else
294310 legacy_collections_info ( coll_name ) . to_a
295311 end
@@ -493,11 +509,27 @@ def drop_index(collection_name, index_name)
493509 # defining the index.
494510 def index_information ( collection_name )
495511 if @client . wire_version_feature? ( Mongo ::MongoClient ::MONGODB_2_8 )
496- result = self . command ( :listIndexes => collection_name ) [ 'indexes' ]
512+ result = self . command ( { :listIndexes => collection_name } , :cursor => { } )
513+ if result . key? ( 'cursor' )
514+ cursor_info = result [ 'cursor' ]
515+ pinned_pool = @connection . pinned_pool
516+ pinned_pool = pinned_pool [ :pool ] if pinned_pool . respond_to? ( :keys )
517+
518+ seed = {
519+ :cursor_id => cursor_info [ 'id' ] ,
520+ :first_batch => cursor_info [ 'firstBatch' ] ,
521+ :pool => pinned_pool ,
522+ :ns => cursor_info [ 'ns' ]
523+ }
524+
525+ indexes = Cursor . new ( self , seed . merge! ( opts ) ) . collect { |doc | doc [ 'indexes' ] }
526+ else
527+ indexes = result [ 'indexes' ]
528+ end
497529 else
498- result = legacy_list_indexes ( collection_name )
530+ indexes = legacy_list_indexes ( collection_name )
499531 end
500- result . reduce ( { } ) do |info , index |
532+ indexes . reduce ( { } ) do |info , index |
501533 info . merge! ( index [ 'name' ] => index )
502534 end
503535 end
0 commit comments