We've now successfully purchased our first ticket.
So for me personally, I have purchased first client ticket right here.
If I view that ticket and try to purchase it again, I am told ticket is already reserved.
So as I mentioned at the end of last video, we should probably try to filter this list right here and
only show tickets that are still available for purchase.
So to do so, we can open up our ticket service, find the route handler that is serving up a list of
tickets and probably alter the query that we are making inside there so that we only return tickets
that are still available.
Back inside my editor, I'm going to find the ticket service.
Inside there, I'll find the Roots folder and then index to yes.
So this is the root handler that we are making a request to you whenever we get that big list of tickets.
And this is the query that we are actually issuing.
So you might recall from our models ticket to yes, file are different ticket documents, might have
an order I.D. property.
It is the presence of that order I.D. property that indicates that a ticket is currently reserved and
cannot be ordered.
So when we write out the query back inside of our root handler to find a list of all of the different
tickets, we can add on a little filter or a little bit of criteria for the query.
We could say only give us tickets where the order I.D. property is undefined or essentially not set.
Inside that object, I'm going to put in order I.D. on defined find all the tickets that don't have
a corresponding order.
Let's save that.
And now if I look back over, refresh the page, I'll see only the ticket remaining that I've not created
an order for.
If I now view that ticket book on purchase, I have created an order for that.
And if I go back over to my big list of tickets now, that big list is empty.
As soon as that order expires.
So I'm not going to pay for it.
I'm going to let it expire and as soon as it expires.
If I then refresh this page, I should see that ticket up here, back on this list.
That was a pretty straightforward solution.
Now, we still have a little bit of stuff to take care of inside of our app, for example, I would
really like to have some links inside the header, so maybe a link right here to create a new ticket.
That's really the goal of this sell tickets link.
We should probably also list out all the different orders that the user has successfully created and
paid for.
So will it create one last page to handle a listing of my orders or orders that correspond to a very
particular user was still a little bit left?
Let's continue in just a moment.