The tests around our two listeners are looking pretty good so I'm not going to start to move on to a
couple of other things.
I put together a quick diagram just to help you understand what we're going to do in the next couple
of videos.
And I did this just because right now we have to tackle a couple of little side topics really quickly.
Just some kind of administrative stuff to make sure everything works as expected and whenever we go
through these kind of Diskin jointed topics it's really easy to get lost and lose sight of what we're
really trying to do.
So this is what we're going to try to achieve in the next couple of videos.
First we're gonna add in the Mongoose update if current module into the orders model.
The reason for this is that we want to add that same kind of version system around orders just as we
have it around tickets.
We're going to eventually emit events or publish a lot of events and listen to a lot of events around
orders changing over time and just like with tickets we need to make sure we process those events in
the correct order.
And so we're always gonna do that by wiring up this update if current module after that.
We're then going to fix up a couple of tests so in particular we're going to make sure that whenever
we are creating tickets inside of our order service we may need to make sure that we provide an I.D..
This is tied to some of the stuff we just went through in the last couple of videos remember we want
to make sure we have a consistent I.D. for all the tickets that are created between our ticket service
and the order service.
However we have a lot of code inside the order service right now that creates tickets without providing
an I.D..
So we have to go hunt around in a couple locations and find those locations and just make sure we provide
an I.D. whenever we create a ticket.
And then finally last thing just a little bit ago we made an update to our cone module and we said that
all of our different events were going to include a version flag.
However we do have two locations inside the order service where we are emitting information or publishing
information about in order and we are currently not including a version property when we are publishing
those events.
And so that those right now are causing a typescript error typescript is saying we want to publish this
event you have to provide a version guess that's it that's a we're going to go through.
Let's start first right now with the Mongoose update if current module in the orders model so inside
my order service I'm going to find the order model file at the very top I will import the
plugin update if current plugin from Mongoose update if current
well then go down to right after our schema right after the order schema we'll throw in here order schema
not set version key and again we're gonna set it to version and then right after that we're going to
tell this schema to make use of that plugin tool at an order schema that plugin and pass an update if
current plugin.
There we go.
Last thing to do.
We're gonna go back up to our order document interface so again remember this describes all the properties
that an order has the Mongoose document interface says that a document has an underscore underscore
of the property which is usually used for checking versions but as we discussed many times we are recording
our versions on a version property.
So just so we can access that version property we have to add it to this order dock interface.
And that's just to make typescript happy and understand that all orders have a version property that
will add inside of your version is going to be a number and that's it go get so that's step number one.
Let's take a quick pause right here.
When we come back next video we're going to fix up a couple of tests.