Skip to content

Instantly share code, notes, and snippets.

@esebastian
Created March 27, 2016 11:01
Show Gist options
  • Save esebastian/19210fc95fc7a70b6c20 to your computer and use it in GitHub Desktop.
Save esebastian/19210fc95fc7a70b6c20 to your computer and use it in GitHub Desktop.
VLCTechHub: event collection `created_at` and `slug` reporter
require 'dotenv'
require 'uri'
require 'mongo'
Dotenv.load
def format_uri(uri)
index = (uri =~ /@/)
index = (uri =~ /\/{2}/) + 1 unless index
uri[index+1..-1]
end
db_uri = ENV['MONGODB_URI']
puts "Listing database at #{format_uri(db_uri)}"
Mongo::Logger.logger.level = ::Logger::ERROR
db = Mongo::Client.new(db_uri)
db['events'].find.each do |event|
created_at = event['created_at']
slug = event['slug']
puts "id: #{event['_id']} created_at: #{created_at} slug: #{slug}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment