I'm trying to put together an association that takes advantage of Mongo's document subkey indexing. For example, I have two collections, posts and topics. Posts have a tags key, which is an indexed set of tags for the post - pretty vanilla. What I want to do though, is have something in my Topic model like:
class Topic
key :name, String
many :posts, :query_conditions => {:tag => lambda {|i| i.name} }
end
The idea being that I have a Topic with a name of "mongomapper", when I invoke @topic.posts, I want the association to be executing the equivalent of:
post.find({tag: "mongomapper"})
I effectively need something like AR's finder_sql option (complete with the ability to interpolate per-instance values into the query), which I haven't been able to find in the MM association options yet. Does anything like that exist?