Meteor Filter For Each December 18, 2023 Post a Comment i have a problem with filter and each. i want create a filter, that will change data according to that filter. allSolution 1: When you manually iterate over a cursor (with each etc) you will have to rewind your cursor to reset it. Taken from the docs http://docs.meteor.com/#rewindThe forEach, map, or fetch methods can only be called once on a cursor. To access the data in a cursor more than once, use rewind to reset the cursor.Therefore you can do something like this:Template.mytemp.datas = function(){ var ac = Session.get("activefilter"); var result = newArray(); if(ac != undefined){ var cursor = RawData.find({filter:ac}); var data = cursor.fetch(); for(var ii = 0; ii < data.length;ii++){ var nData = NextData.findOne({_id : data[ii].Next_ID}); result[ii] = { Name : nData.Name }; } cursor.rewind(); //we rewind our cursor here so that it can be iterated again from the beginning when neededreturn result; } }; Copy Share Post a Comment for "Meteor Filter For Each"
Post a Comment for "Meteor Filter For Each"