Skip to content

Instantly share code, notes, and snippets.

@lalitlogical
Created September 23, 2019 16:59
Show Gist options
  • Save lalitlogical/2564747c5195c8aeccd5ecb0f82f0da9 to your computer and use it in GitHub Desktop.
Save lalitlogical/2564747c5195c8aeccd5ecb0f82f0da9 to your computer and use it in GitHub Desktop.
Get MongoDB collection list
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'database name')
client.collections.map {|c| puts c.namespace.gsub('database name.','') }.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment