Is it possible to perform a query and return the embedded documents?
Currently, I have:
class Post
include MongoMapper::Document
many :comments
end
class Comment
include MongoMapper::EmbeddedDocument
belongs_to :post
key :author
key :date
key :body
end
Here is a query that is almost there:
Post.all("comments.date" => {"$gt" => 3.days.ago})
This will return all the post objects but not the comments. I guess I could do something like:
Post.all("comments.date" => {"$gt" => 3.days.ago}).map(&:comments)
But this would return all comments from the posts. I'd like to get all of the comments that met this condition. Perhaps Comment
should not be embedded.