Method: Mongo::Database#list_collections

Defined in:
lib/mongo/database.rb

#list_collections(options = {}) ⇒ Array<Hash>

Note:

The set of collections returned, and the schema of the information hash per collection, depends on the MongoDB server version that fulfills the request.

Get info on all the non-system collections in the database.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :filter (Hash)

    A filter on the collections returned.

  • :name_only (true, false)

    Indicates whether command should return just collection/view names and type or return both the name and other information

  • :authorized_collections (true, false)

    A flag, when set to true and used with nameOnly: true, that allows a user without the required privilege to run the command when access control is enforced.

  • :comment (Object)

    A user-provided comment to attach to this command.

    See mongodb.com/docs/manual/reference/command/listCollections/ for more information and usage.

Returns:

  • (Array<Hash>)

    Array of information hashes, one for each collection in the database.

Since:

  • 2.0.5



167
168
169
# File 'lib/mongo/database.rb', line 167

def list_collections(options = {})
  View.new(self).list_collections(options)
end