mongoid query problem
I am trying to achieve the equivalent of this in mongoid (mongoid.org ORM):
select * from parents
inner join children
on parents.id = children.parent_id
where children.created_at <= some_timestamp
Parent embeds a child, A child belongs to a parent
I have no issues up to this point: Parent.where(:child.exists => true), but I have no idea how I am supposed to do the equivalent of 'child.created_at'.lt => some_timestamp (Illegal to use a method on st开发者_如何学编程rings.)
Thanks
Mongoid uses UTC Timestamps internally, to work with a date in a query you can do the following:
:'child.created_at'.lt => Time.now.midnight.utc
精彩评论