Hi, I am trying to use a PostFetch hook to filter certain results from my collection. I have a set of dates that I am trying to filter. I only want the response to be those dates that are today or in the future. I can determine which are which in my logs using my code but no matter what I do I can't seem to get the code right to filter out those dates that have passed. I currently have it set up to just pass all, how can I get this filtering to work? Any help would be appreciated.
One thing to consider is to use [Mongo operators](http://docs.mongodb.org/manual/reference/operator/query/ "Mongo operators") in your query itself rather than trying to do this in BL post-fetch.
over 8 years ago
One thing that is happening is that you're calling response.continue within your for loop. Response.continue returns the response and halts further processing, so on the first pass through the loop, you are returning without processing the other items.
It gets tricky trying to remove array items within a loop, because when you remove an item from an array, the array gets reindexed. There are two approaches to accomplish what you are after:
Create an array to hold the elements that you want to eventually return, and then replace response.body with this new array
var eventDate = "";
var filteredResults = ;
for (var i = 0; i eventDate= response.body[i].date;