r/Meteor•
voidZero-

Quick Question: Separate data from multiples subs in client

I'm subscribed to several publications that are publishing a lot of data to the same collection. In client I'm having to remake all queries I did to publish the data so I can separate which data is about each sub.

This seems redundant to me, but I found no better way, except by publishing each data to a separate client-only collection using publish-composite package.

The question is: is this a bad practice? what is the down side? is it gonna take a tow in scalability or client performance?

Posted Jun 12, 2015, 9:30 PM UTC

15
exomind•

I tend to stick a function in /lib that takes some parameters and returns an object for querying the collection. That way, usually all I need access to is a few properties/URL parameters, and I don't have duplicate queries everywhere. A function called in multiple places seems sufficiently less redundant to make this a non issue, for me at least.

2
cmn_jcs•

Could you consolidate the publish statements into one publish (and probably just send down the whole collection, unless there's something that shouldn't go down), have one subscribe, and then make cursors as appropriate?

1
voidZero-OP•

I think I didn't explain myself properly. The publications are about two different ideas, so they must be separate. The problem is that the docs for sub1 are published separate from the docs from sub2, but in client they are put together, so I have to separate them again and it seams redundant.

1
cmn_jcs•

Why must they be kept separate?

1
voidZero-OP•

they don't need to be kept separate, it just would be easier than making another query. in server the query returned by each subscription is rather complex, and I have to make the same one in client. if the client collections where separate, i could just make a global query collection.find({})

1