All right, and before we start sending up JSON Web tokens, since we'll do that in the custom instance
method, the document custom instance method.
Why don't we set that one up first?
Do a simple console.log online and we will add all the functionality as far as the JSON, what tokens
are concerned?
Again, I left the link here so I can bravely navigate here.
You can read that documents are instances of the models, and they do have a bunch of built in since
methods meaning in one of the previous videos, I showed you user -.so.
So that is the built in one part.
We can also add our own custom ones and the way that looks like we go with the schema of methods.
So this is a key word.
Make sure that you Typekit exactly as they show here and then the name of the function.
So in our case, that is going to be create JWT.
And again, what's really called that in this function, we can access our document using this.
So we pass in the this online.
We can access whichever property we want, and then we'll call this one actually in the controller because
that's where we create that document, correct?
Now keep in mind, we'll set it up in the user model, but we'll call it in the controller.
And if you're kind of iffy on this one, don't worry, we'll get there in no time.
So the first thing that I want to do is navigate back to my user model.
And then since my schema name is user schema.
We're going to go with user scheme one methods and then create JWT again.
I'm going to use good old function keyboard and I'm going to go with console.log and enlarge the controller
right after we create my user.
Let's invoke it.
Let's just see what do we have here in the console and yes, in between the videos.
Again, I removed my good old John from the database, so I don't have to worry about that in the postman.
So back in the user one, let's just set it up right off 30 preset rock where we're going to go with
users scheme dot van methods and then we're going to go create jaded worker.
So this is a function name you can call this vegan food truck.
It doesn't really matter.
And in my case, I'm going to go with function and set it up and in function body.
Like I said for time being, let's simply go with Log Angus because I want to showcase that we can always
access our document and not in the off controller.
Like I said, once we create the user before we send it back.
Let's go here and let's say user.
And now we have that custom instance method so I can go and create JWT so I can invoke it.
And now I just need to navigate back to my postman.
And in here, let's send it one more time, and this value is going to be exactly the same.
What I'm interested is my console, and here I can actually see that I access all the values and will
use this when we're setting up JWT because we'll have to grab some values from our document and pass
it in to JWT.