I have a group model. I want to query a group to see if user exists in it. Typically this is much easier using embedded documents but unfortunately I cannot do that in this case. In an embedded scenario I would do the following. How can I do this query in a referenced scenario.
Note:** I do not want to use habtm relationships.
Query
Matter.where(:'matter_counsels._id' => the_id)
Classes
class Matter
include Mongoid::Document
# Relationships
has_many :matter_counsels # subclass of MatterRelationship
has_many :matter_clients # subclass of MatterRelationship
has_many :matter_opposing_parties # subclass of MatterRelationship
has_many :matter_related_parties # subclass of MatterRelationship
end
class MatterRelationship
include Mongoid::Document
belongs_to :matter
end
I have to admit the example I had above wasn’t clear. I updated the problem along with my solution.