Is there a method in Criteria that will print the actual MongoDB query that criteria is generating?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you inspect Mongoid Criteria instance, you will see “selector” which maps (essentially) directly to the MongoDB selector. However Mongoid Criteria can be chained and are evaluated lazily, so the result of chaining and lazy evaluation is not available until you do an actual DB operation. So if you want to see the final result, you should look in the appropriate log. For a test, this is log/test.log, for “rails c” console, this is log/development.log — this is standard.