Last active
December 17, 2015 03:28
-
-
Save GregIngelmo/5542927 to your computer and use it in GitHub Desktop.
Interactive Mongo queries
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
# Launch pry based interactive Rails console | |
$> pry -r ./config/environment.rb | |
# redirect Mongoid logging to console | |
pry(main)> Mongoid.logger = Logger.new($stdout) | |
# run a query | |
pry(main)> User.where(:username => "greg").first() | |
# Mongoid spits out the query, but, I actually want to see the raw Mongo query | |
MONGODB (515.5ms) development['users'].find({:username=>"greg"}).limit(-1).sort([[:_id, :asc]]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment