Method: Mongo::Database#collection_names

Defined in:
lib/mongo/database.rb

#collection_names(options = {}) ⇒ Array<String>

Note:

The set of returned collection names depends on the version of MongoDB server that fulfills the request.

Get all the names of the non-system collections in the database.

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

Parameters:

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

Options Hash (options):

  • :filter (Hash)

    A filter on the collections returned.

  • :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.

  • :timeout_ms (Integer)

    The operation timeout in milliseconds. Must be a non-negative integer. An explicit value of 0 means infinite. The default value is unset which means the value is inherited from the database or the client.

Returns:

  • (Array<String>)

    Names of the collections.

Since:

  • 2.0.0



143
144
145
# File 'lib/mongo/database.rb', line 143

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