lib/mongo/database/view.rb in mongo-2.11.6 vs lib/mongo/database/view.rb in mongo-2.12.0.rc0

- old
+ new

@@ -76,16 +76,22 @@ # version that fulfills the request. # # @example Get info on each collection. # database.list_collections # + # @param [ Hash ] options + # + # @option options [ Hash ] :filter A filter on the collections returned. + # See https://docs.mongodb.com/manual/reference/command/listCollections/ + # for more information and usage. + # # @return [ Array<Hash> ] Info for each collection in the database. # # @since 2.0.5 - def list_collections + def list_collections(**options) session = client.send(:get_session) - collections_info(session, ServerSelector.primary) + collections_info(session, ServerSelector.primary, **options) end # Create the new database view. # # @example Create the new database view. @@ -155,18 +161,21 @@ { selector: { listCollections: 1, cursor: batch_size ? { batchSize: batch_size } : {} }, db_name: @database.name, session: session - }.tap { |spec| spec[:selector][:nameOnly] = true if options[:name_only] } + }.tap do |spec| + spec[:selector][:nameOnly] = true if options[:name_only] + spec[:selector][:filter] = options[:filter] if options[:filter] + end end def initial_query_op(session, options = {}) Operation::CollectionsInfo.new(collections_info_spec(session, options)) end def send_initial_query(server, session, options = {}) - initial_query_op(session, options).execute(server) + initial_query_op(session, options).execute(server, client: client) end end end end