Created
March 27, 2016 11:01
-
-
Save esebastian/19210fc95fc7a70b6c20 to your computer and use it in GitHub Desktop.
VLCTechHub: event collection `created_at` and `slug` reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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