I want to implement publication with parameters in Meteor, but I am having some problems.
Here is what I have.
How the user enters the keyup event, which subscribes to the publication and passes the input value.
'keyup #customerSearch': function(event, template){ var keyword = template.find('#customerSearch').value; if(keyword){ if(keyword.length >= 3){ Meteor.subscribe('sessioncustomers', keyword); } } }
The publication uses this keyword to return records.
Meteor.publish("sessioncustomers", function(keyword){ if(keyword ){ if(keyword.length >= 3){ query.name = new RegExp(regExpQuoted(keyword), 'i' ); Customers.find(query); } else { return null; } }else{ return null; } });
Problem. It works and documents are accepted, unless the client changes the keyword or, rather, as the keywords change, the publication publishes additional documents matching the keywords, but the collection of clients never deletes old documents.
How to get old documents that no longer match the customer collection?
I thought that since the subscription options have changed, that inconsistent documents will be unsubscribed and only new relevant documents will be signed.
source share