I am using reywood:publish-composite for reactive joins. The code is below. Two problems:
-
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.
-
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}});
}
}]
}
});