Ruby Mongo Driver: How To Look For Date Intervals?
问题 Given a init date and today, what's the query to search for all "names" between that date? Thank you 回答1: MongoMapper You should be able to use MongoMapper's query operators. Suppose your have a "User" model with a "created_on" date, you could use this to get the names. (I believe MongoDB uses UTC Times to store all date/time objects): initial_date = Time.utc(2011, 5, 1) # 2011-05-01 00:00:00 UTC @users = User.where(:created_on => {:$gte => initial_date, :$lte => Time.now.utc}) @users.each do