Hi all. I have a question on including fields from joined collections.
When I reference a joined collection with include_fields, can I be selective about what from that second collection is returned without impacting the main collection results?
Something like: &include_fields=$catalogs(name,user_id:= user_a) would return the related catalog.name that was for user_a, but not restrict products that had no catalog reference for user_a.
If I use filter_by I only get back documents from the main collection that are related to matched records in the joined collection. But can I accomplish above where I get back all matches from the main collection, but augmented with only certain matches from the joined collection?
Here is the background:
I have a primary collection (products) with a document for each product. In our system, users can create catalogs of products, and these catalogs can be shared to other users. I'd like a user's search results to have a facet with any catalogs they have access to for the products in their search results. Products and catalogs have a many to many relationship.
I have all the catalogs a product is part of on the product document. My thought was another collection (catalogs) joined on those catalog IDs with the details of each catalog (like which users can see it).