include one attribute of other collection in mongoid rails Query
I want to query with mongoid , I have following models
class Score include Mongoid::Document field :value, :type => Integer belongs_to :user end class User include Mongoid::Document field :name, :type => String field :age, :type => Integer has_many :scores
I want to query all the scores from collection with their users. but users object should have only have the 'name' field in it
I would be something like
Please tell the correct syntax for this
Score references User, so it is not possible to retrieve them both in one query, because there are no joins in MongoDB.
Either denormalize and include user name in Score or do several queries.