There are two last remaining small tasks we have to take care of around processing feedback on surveys.
First we need to make sure that we implement this last responded at date whenever we update a schema.
Now this is going to be pretty straightforward.
So I'm going to flip back over to our route handler.
Here is our query where we attempt to update the one particular survey.
And down inside of our update criteria object right here.
So this is our update criteria.
We're going to add on one more key value pair.
We're going to say also update the last responded property and set it to the new date like so.
So pretty straightforward not too bad.
Now I'd said there was one other thing we need to take care of as well.
If you recall at present we scroll up a little bit.
We were sending back a little thank you message to any user who voted on one of our surveys.
But right now that is broken and so users are seeing a 404 response whenever they click on a link inside
of an email.
So we can easily fix the thing up right here.
The only tricky part is that you need to remember that now whenever a user clicks on a route they're
going to be sent to a route that looks a little something like this something of API slash surveys.
Colon survey ID colon choice.
And so we need to make sure that we kind of encode these wildcards inside of this link as well.
So we're going to say that whenever someone goes to API slash surveys slash colon survey ID slash colon
choice still send them the message back of thanks for voting.
So whenever we are putting together express route handlers and we want to go in some wild card we treated
just the same way we did with this path handler down here.
You put down a colon and then some property name or some variable name whatever you want it to be and
then express will try to greedily match that against incoming requests.
So let's now test this stuff out.
I'm going to save this.
I will flip back over to my browser and I'm going to use the same e-mail that I did before.
So when I click on yes on here and when I do you'll see that we are again shown the message.
Thanks for voting.
Now just to save us a little bit of time.
I also already went through and tested out the last responded at data as well.
So if you want to test that you will need to make sure that you send yourself a new survey because you
have already probably used up the survey that we created for a super final test.
And so you will not be able to make another response because you've already used this link once before.
You've already voted on the survey.
So you might want to create a new survey over here and send it to yourself to test the last updated
at Flag or time stamp.
But like I said I already tested out ahead of time so we didn't have to take more time to check it out.
So I'm looking at the very particular document again of super final test.
And if I scroll down towards the bottom I should now see last responded with the date of basically now
on here as well.
Now one one other quick tip if you want to not have to constantly send yourself new surveys you can
always find your personal e-mail right here that you are testing off of and you can just manually change
the responded flag over to a false go down towards the bottom of the document and click on Save and
go back.
So now your e-mail is recorded as not having given feedback on that particular survey before.
So I could go back over and reuse the same survey again by clicking on yes.
Again just a little tip that you might want to try to use if you want to do some very rapid fire testing
without having to always go back and do another survey creation.
OK.
So I think that pretty much wraps up collecting feedback around surveys.
I can't really think of anything else we need to really need to do around this.
So I do want to take a quick break now.
And I had mentioned that I was going to show you a couple of little tips around putting together queries
to work with Mongoose and Lango DVH.
So let's take a quick pause and then I'll show you some of those tips inside the next section so I'll
see you in just a minute.