I’m getting a bit confuse with the rails console.
I’m trying to connect to my database to explore the way it works.
It’s all fine when I connect and do basic things like
#get Day database
Day.first
Day.last
Day.find('4f272afce096a47ccd000002')
But when I try queries like those:
http://mongoid.org/docs/querying/criteria.html
This is what I get:
Day.where(name: "monday")
=> #<Mongoid::Criteria
selector: {:name=>"monday"},
options: {},
class: Day,
embedded: false>
And that’s when I’m lucky
You’re getting a cursor-like “criteria” back. Criteria are lazily evaluated, so you can chain operations off of them. Try
Day.where(name: "monday").first. More specifically,“All queries in Mongoid are Criteria, which is a chainable and lazily evaluated wrapper to a MongoDB dynamic query. Criteria only touch the database when they need to, for example on iteration of the results, and when executed wrap a cursor in order to keep memory management and performance predictable.” link