I already use publishComposite for situation where I need to do joins of data between two collections, but I also have a case where I need to simply combine two collections.
For example, I have an activity feed where I need to show, in the same template, documents from two collections (in my case, ‘articles’, and ‘events’) in a wall-type format (like facebook wall)
At this point I cannot denormalize the data, and I need to combine the docs and keep them in an order by their ‘created’ field, while maintaining some limits on the number of returned results with the ability to page.
Is there an established technique or practice for this (besides de-normalizing)?
Maybe I posted too soon…this stack exchange answer looks very close:
basically: doing the concat in the template helper.
I think you have a typical case of Grapher from the Cult of Coders. https://cult-of-coders.github.io/grapher/
well, grapher looks insanely cool, so thanks for that link.
Reading the docs though, it seems to be a more robust and feature-rich version of publishComposite, ie, the ability to do reactive joins, denormalization of fields etc.
However, I was unable to see an example of how to use it for my use case where I just want to ‘concat’ collections. In my example there is nothink linking my ‘events’ collection with my ‘articles’ collection to be joined on…I simply want documents out of both of them sorted by creation date.
If I am missing something about grapher, please let me know, because it does look awesome.
I’d rather create a third collection
eventId, eventType, timestamp and limit/sort/skip on it.