Mongoid - querying by referenced document?

The problem is that MongoDB doesn't have any way of mapping a Category record to an Ad record. All it knows is that an Ad record has a category_id field so category. Domain_id will always return nothing.

The dot notation inside queries works only for embedded documents, not references (which are still second-class citizens in MongoDB).

The problem is that MongoDB doesn't have any way of mapping a Category record to an Ad record. All it knows is that an Ad record has a category_id field so 'category. Domain_id' will always return nothing.

The dot notation inside queries works only for embedded documents, not references (which are still second-class citizens in MongoDB). So to solve your problem, you'll need 2 queries: category_ids = Category. Where(:domain_id => domain.Id).

Map(&:_id) Ad. Where(:category_id. In => category_ids).

Yes, but I also need to get all subcategories of category(including sub-sub and sub-sub-sub...). I have implemented it using MapReduce(after my attempt to use ids collection with recursive function). – Andrey Kouznetsov Dec 7 '10 at 13:44.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions