Created
July 21, 2011 21:04
-
-
Save solars/1098195 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Daterange | |
include Mongoid::Document | |
field :from, type: Date | |
field :to, type: Date | |
end | |
class Person | |
include Mongoid::Document | |
field :name, type: String | |
embeds_many :dateranges | |
end | |
Person.delete_all | |
Daterange.delete_all | |
p = Person.create(name: 'myname') | |
p.dateranges << Daterange.create(from: Date.today, to: Date.today+1) | |
p.dateranges << Daterange.create(from: Date.today+5, to: Date.today+10) | |
p.save | |
puts Person.where('dateranges.to' => {'$gte' => '2010-11-01'}).first.inspect | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment