javascript - Meteor - Return Collection Object from Method -
I am trying to return a set object based on metric system based on a set session.
Here is the method call:
Template.batches.search = function () {if (type of session. Search ('search-parameter')! = 'Undefined ') {var searchParameters = session. Received ('search-parameter'); Return Meteor.call ('Search', search parameter, function (error, result) {if (error) {console.log (error.reason);} else {return result;}}); }} This method is being called L
Meteor.methods ({search: function (session) {return batches.find ({ Event: {$ Regex: session}});}}}; I have read that no method can return the collection object and instead of using the fetch () it gives an array, however, to return the result, a colleciton I'm unable to iterate over an array like an object. Please advise.
Template assistants should be synchronous, there are some ways to resolve it, but this is an example: / P>
Template.batches.created = function () {// This will be cleared for you when the template will be deleted. Autorun (function () {var search = Session.get ('search-parameter'); Meteor.subscribe ('batchesFor search', search);}); }; Template.batches.helpers ({search: function () {var search = Session.get ('search-parameter'); return batches. Search ({Event: {$ regex: search}});}}); batches in batches template, create an autorun that subscribes to batchesForSearch , whenever the session changes once When documents come to the customer, they will make your template available through the search assistant. batchesForSearch The published function may look like this: Meteor.publish ('batchesForSearch', function (search) {check ( Search, string); if (_.isEmpty (search)) // Make sure that we do not publish the whole collection if the search is empty, then clear it. ();} And {return batches Search ({Event: {$ Regex: search}});}}); Note that we are careful to avoid publishing the entire collection when the search is empty.
Comments
Post a Comment