Reywood:publish-composite pagination problem

I am using reywood:publish-composite for reactive joins. The code is below. Two problems:

  1. Limit does not seem to work properly. I have to limit the find and the child to the exact same number or it returns all docs.

  2. If I call for the first 300 docs and the ask it to publish the last 300 (same view) it will neither clear the first 300 nor load the last 300.

    Meteor.publishComposite(‘taggedContactsFirst’, function(tagId, contactId) {
    Counts.publish(this, ‘inTag’, Tagged.find({userId: this.userId, tag: tagId, contact: contactId}), {nonReactive: false});
    return {
    find: function() {
    return Tagged.find({userId: this.userId, tag: tagId}, {limit: 300, fields: {contact: 1}})
    },
    children: [{
    find: function(tagged) {
    return Contacts.find({userId: this.userId, _id: tagged.contact}, {sort: {last: 1, first: 1}, limit: 300, fields: {first: 1, last: 1, nameLast: 1, nameFirst: 1}});
    }
    }]
    }
    });

    Meteor.publishComposite(‘taggedContactsLast’, function(tagId, contactId) {
    Counts.publish(this, ‘inTag’, Tagged.find({userId: this.userId, tag: tagId, contact: contactId}), {nonReactive: false});
    return {
    find: function() {
    return Tagged.find({userId: this.userId, tag: tagId}, {limit: 300, fields: {contact: 1}})
    },
    children: [{
    find: function(tagged) {
    return Contacts.find({userId: this.userId, _id: tagged.contact}, {sort: {last: -1, first: -1}, limit: 300, fields: {first: 1, last: 1, nameLast: 1, nameFirst: 1}});
    }
    }]
    }
    });

Are you by any chance using subscription manager to cache subscriptions?

No I’m not using subscription manager.

About #1, take a look at https://github.com/englue/meteor-publish-composite/issues/39 where it basically explains the child is fetched per document returnd from the parent find, therefor the limit being applied to the specific subset per parent, therefore the sum of all child datasets being more than the “total” limit you thought would have applied!

And #2 can be solved by using separate client side collectionNames as described here: http://braindump.io/meteor/2014/09/20/publishing-to-an-alternative-clientside-collection-in-meteor.html

1 Like