Skip to content

Instantly share code, notes, and snippets.

@FrancescaK
Created December 27, 2011 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescaK/1525359 to your computer and use it in GitHub Desktop.
Save FrancescaK/1525359 to your computer and use it in GitHub Desktop.
get MongoDB from within the Rails Console
collection.find({:request_time => {'$gt' => Time.utc(2010, 11, 18, 22, 59, 52)}})
collection.find({"controller" => "order", "action"=> "show", "params.id" => order_id})
collection.find({:request_time"=>{"$gte"=>Time.utc(2011, 11, 18), "$lt"=>Time.utc(2011, 12, 18)}})
collection.find({:runtime => {'$gt' => 1000}})
db = Rails.logger.mongo_connection
=> #<Mongo::DB:0x007fdc7c65adc8 @name="monkey_logs_dev" ... >
>> collection = db[Rails.logger.mongo_collection_name]
=> #<Mongo::Collection:0x007fdc7a4d12b0 @name="development_log" .. >
collection.find({"is_exception" => true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment