 Hey everybody, this is Brian. Welcome to the 13th yeet tutorial. Oh, lucky 13. Halloween's coming up soon All right, if you've been following along, we've been creating records. We created two records in the teacher's class named Slardie Bartfast. If your hitchhiker guide to the Galaxy fan dropped me a note It was an awesome book All right, so let's jump back in where we were In case you haven't been following along, let me digress for a second here. If you go out to the site We have added a test View or I should say a test action into the teacher's class And we've just been dumping an object out there as we create it just for the sake of seeing what's going on All right in the test action, you can see how we've been creating it. I'm just gonna comment this out All right now what we're gonna do is we're going to actually find a Record out in the database Sorry cat was distracting me Now notice how what we're doing is we're calling the teacher's model the static object And then we're getting the internal model from the object And we want the find function and you notice how there's a whole gob of them you can find you can find by attribute and You'll get Different things like you can find a single record. You can find multiple records. You can find all the records We're looking for a specific one. So let's do this guy right here Find condition equal and then prams array so Now Sometimes I don't like net beans autocomplete, but we're just going to deal with it for a minute here So the prams is an array So what we need to do here is we want to find a specific model And by a specific model, I mean a specific record So we're creating a variable called model. We're saying teachers, you know the static reference to it And the model internal class we're going to find and we're looking for a specific criteria So let's just randomly pick one here Let's find I need to go on anybody anybody going once let's find John dough John dough needs to die. So let's go here And we'll say Now that right there should look very archaic to you What we're doing is we're saying the field in the database needs to equal And then we have a parameter ID and this is where the parameter ID comes into play If we just said name you will treat that as a string literal meaning It'll say first name equal name if we do that add that little colon in front of it You will say first name equals parameter ID of name which is in this array that we're passing as a parameter That's a mouthful So if we go back here and we just refresh the page Sure enough, there's John dough. So we've actually loaded that record and we can see the ID of John dough is eight So let's do a little bit of coding here and we're gonna actually just delete this record here Actually, let's not delete it. Let's modify it. I'm gonna save delete for another tutorial And we're gonna say last name John Hancock You'll John Hancock when you write your signature And we're going to actually save this and of course it got bigger because we're loading more That's how it's now Hancock instead of John Doe and if we go out to the database And there's John Hancock pretty simple pretty easy Some pitfalls you should understand I want to explain in this tutorial, but we'll actually go over in future tutorials if you hit save And it doesn't actually save to the database You need to validate it and validate will return a bull and what that does is if you have specific database rules For example, like if you say first name cannot be blank Validate will make sure that it's not blank. So I just want you know, if you're At home playing around with this and it doesn't save that's something you should look out for And we're going to go over validation in a future tutorial. I'm trying to keep these really short and simple and to the point So that's how to find a record modify it and save it back to the database