Need help on a composite publish



kind of a beginner in MongoDB and I’m running into one issue which might or not be solved by meteor-composite-publish.
I have a collection of events like this:

{category:A, path:A1, content:"", createdAt:"11/10/2015"}
{category:A, path:A1, content:"", createdAt:"11/11/2015"}
{category:A, path:A1, content:"", createdAt:"11/12/2015"}
{category:A, path:A2, content:"", createdAt:"..."}
{category:A, path:A3, content:"", createdAt:"..."}
{category:B, path:B1, content:"", createdAt:"..."}
{category:B, path:B2, content:"", createdAt:"..."}
{category:B, path:B3, content:"", createdAt:"..."}

I want to be able to do 2 things:

  1. Publish the latest events created for each path, together; the path are dynamic, so I cannot use a predefined query
    In my case should be:

    {category:A, path:A1, content:"", createdAt:“11/12/2015”}
    {category:A, path:A2, content:"", createdAt:"…"}
    {category:A, path:A3, content:"", createdAt:"…"}
    {category:B, path:B1, content:"", createdAt:"…"}
    {category:B, path:B2, content:"", createdAt:"…"}
    {category:B, path:B3, content:"", createdAt:"…"}

  2. Publish the latest events created for a specific category

Probably some kind of aggregation would be nice, but don’t know what to use :frowning: Any advice for me?


Nobody? Maybe I should just create a collection to hold path objects ({path:A1, category:A1, _id:something}). Denormalisation might allow me to use meteor-composite-publish…