Placeholder Image

Subtitles section Play video

  • Hey, this is Henry.

  • And welcome to cease tutorial.

  • What we're going to be doing today is building a simple, too dear list with the Prince Tak.

  • And in case you don't know what the Prince Tak stands for, it is P for Post Grass E for express our for reaction?

  • Yes, as your friend and framework at an end for no Gs as her back in language.

  • Now, by the end of this video, you'll have you better understanding of how all these different types of technologies interact with each other and go on to building more complicated applications.

  • Now, let me give you guys a quick demo.

  • So let's say I need to clean my room.

  • Wish I really need d'oh so I can add that I can even edit the information.

  • So let's change this to car.

  • Uh, I'll just keep it like that.

  • And then I can also delete the information.

  • So even though this is just a simple crowd application and it is trivial, there's a lot of things that's happening between the front and back end.

  • So in the next section, we're gonna go over a diagram or review of how this application is going to work and give you guys the big picture.

  • Now, before I move on, there is going to be some pre represents or more like, pre set up.

  • Like the first thing you're reading need is to have no gs installed.

  • Second, you also need to have post grass installed.

  • And if you don't, I'm just gonna give you guys a video.

  • That's why I'm gonna look at the bottom of my video That's going to show you guys how the properly install it.

  • Besides that, you guys need to have a basic understanding.

  • What jobs?

  • Grab reaction.

  • Yes.

  • And if you understand recipe ice, that's going to hell.

  • So help you guys a lot throughout the whole process.

  • But besides that, I'll see you guys in the next section.

  • Okay, so let's just quickly go over this diagram to get the big picture so you can see that this is going to be our friend.

  • And so right here you could see that the submit button along with the data that's going to be able to get edit and deleted.

  • So any time I collect the submit at it or delete button within my react application what I'm really am doing is sending an http request to my rest.

  • Will FBI and depending on the HTP requests and the route that's being hit, it is going to tell my database or it's going to instruct my database.

  • A rod type of crowd operation needs to get done.

  • Okay, so any time I like the Smith, But it I'm sending a post request to create a to dio Anytime I want to edit something, I'm sending a poor requests toe update to dio delete, delete.

  • And then when I want to read it to do, I'm gonna use it.

  • Get request.

  • So I think one of the hardest part about learning how false like application work is really understanding rest wapi eyes.

  • So I'm gonna really oversimplify the definitions.

  • But this is really all you need to know.

  • Arrestable e p.

  • I uses transfer protocol in order to run credit operations.

  • So what I mean by that is that our transfer protocol is going to be htp requests.

  • So we have access the post, put lead, get in a lot more, but these air the for me once.

  • But essentially, we're going to be using these htp requests and then our rational FBI is going to take them.

  • And then it's going to instruct.

  • The keyword is in struck our database.

  • Ah, what type of crowd operation needs to get done?

  • Okay, so a lot of misconception that a lot of people have is that credit operations occurred within the rest weepy I but that's not true at all.

  • Broader the crowd operations on Lee occur within the database.

  • Wonder that's post cries or mongo D B or my SQL.

  • It only occurs within our database.

  • So I'm just going to say this arrest FBI is just going to take our htp requests and it is going to instruct.

  • Okay, so hopefully that makes a lot more sense.

  • And in next section, we're going to start building arrest way.

  • P I Okay, so let's start building our wrestle a p I.

  • So the first thing I did was created a simple pern to Dio folder, and you can name this whatever you want, but really, the big idea is that it's going to hold our client and server folder.

  • So I'm gonna first do my dear server.

  • And then I'm going to see the into that server.

  • So you could see your It's popping up right there and immediately I'm going to run and PM in it.

  • So mpm and it is going to keep track of all our packages insider application.

  • And we're gonna answer a few more questions to give more details.

  • So entry point is what's going to glue or application together.

  • So after that, I'm going to do and PM, install, express, PG and course.

  • So what are these libraries?

  • Well, express allows us to quickly create a server in No J s, and then we, of course, which allows different domain applications to interact with each other.

  • For example, our service gonna be running on Look, host 5000 in our react applicators application is going to be running on local host 3000.

  • Finally, PG is there to connect our database with our server it in order to run some post grad queries.

  • Okay, so once we set this thing up, I'm going to see touch.

  • Indyk said yes, which is going to get to be the glue.

  • I'm gonna go over here, record the libraries, so I'm gonna require express, and then I'm going to create a variable called up, which is going to take my express library and then it's going to run it.

  • Now I pause all these cool methods in order to create a server.

  • So any time we want our server to start, we have to listen to a part number.

  • So I thought, listen for 5000 is what we're gonna will be listening to, and then I'm gonna have a callback function that's going to indicate has started.

  • So server has started on port.

  • I testes out really quick to see if it works.

  • I'm going to say node index, and indeed it does work.

  • But the thing is, is that I don't want to use note.

  • I highly recommend that you mpm sell globally Nordmann because every time we want to see changes, we have to restart terminal and turn it back on.

  • So by using no men or no mom, you're going to watch a single file and then every time there's a change that's going to be done, it's going to onsen instantly.

  • Restart it.

  • So no, mom and you can see it's going to be watching our file.

  • And the next thing I want to do is create Cem Mil where so middleware.

  • I'm gonna use up that use.

  • So anytime we're gonna create a middle where you have to use about use and I'm gonna put course, And I totally forgot to require that.

  • So constant cores.

  • Okay, so now that set up, that's all we have to do.

  • And I just kind of wanna jump ahead a swell, that any time we're building a full psych application, you need to get data from the client side.

  • And the only way to get data from the client side is that we have to get it from the requests that body object.

  • So let me show you how we could do that.

  • So by using this oops, we go back inside here.

  • So this right here essentially is allowing us and gave us access to request that body and then we can get Jason data.

  • Okay, so this is still a little bit confusing.

  • We're going to build and I'm going to wreck consists a lot.

  • Okay, so I'll see in the next section, and we're gonna create a database and a table for a post cries.

  • All right, so let's get started building our database in table, so I'm gonna first show you guys this diagram to give you guys a big overview of the commands we're gonna be using.

  • So you could see this or post Crest inside there.

  • There's gonna be a lot of other databases like to do databases or hotel database.

  • Now, inside these data basis, we're going to have a table.

  • So in this case, I'm going to create a table or I'm gonna create a database call to do Davies.

  • And then inside there, I'm going to create table called to d'oh.

  • Another purpose of having a table is that if there's anything that's related to room, for example in this database that it's gonna be placed inside the room table, anything that's related to guests is going to be placed inside the guest people, Okay?

  • And writing a database for creating a database is as easy as saying create database and it specifying the name along with Semi Colon.

  • And then after that, we have to move inside that database and then we have to run, create table to dio.

  • We don't stop there.

  • We also have to define a schema.

  • And the reason why s Cuma is so important is because we don't want to put anything inside her database.

  • You want to be specific on what we're going to be putting inside there.

  • And then finally, as you can see here, we have all these separate commands that you can run but in our post grad terminal, nowhere to make it easy for us to move around.

  • So let's get started.

  • So I'm gonna go back to my visual studio code, and right off the bat, I'm going to create a file called Database Thought SQL.

  • And the reason I created this is because it's going to make it more visually pleasing when we write our commands.

  • So that's pretty database.

  • So great database and record to name it as pern to d'oh!

  • All right, semi colon and the next records say create table and in to d'oh.

  • Now I have to specify what's going to look like.

  • So let me just set this little pregnancies.

  • First thing I'm gonna do is to do I D.

  • And the reason why I have to do idea is because I want to ensure that this to do is going to be unique.

  • For example, any time I'm trying to delete, I'm trying to update or get a specific to do.

  • I just want a reference this to do I d.

  • Because it's what's going to make it distinguishable from the other two Dios.

  • And then I'm going to say serial Hi, Murky.

  • What is this?

  • So primary key is exactly what I just said.

  • Last time essentially indicates that this value right here where this column is going to make this entire to do unique from the other two DUIs.

  • And then we have cereal, which is going to be this function that's going to increase our primary key to ensure uniqueness.

  • So if you're still looking confused, don't worry about it.

  • We're just gonna go over that wall.

  • We called this thing and finally, I'm just going to have description inside here, and I'm going to say, uh, give a far char of 2 55 which means I'm setting a Max character of 255.

  • We just wrote our commands, and now you should already have installed post grass.

  • So let me just put this aside.

  • So I'm gonna open this command line right here, So you should already stalled it.

  • And then what you're going to run is P SQL Dash you representing as the user, and we're gonna be using the user Post press.

  • So ain't time we installed Post Press?

  • You automatically have a user by default called Post Press, which is a super admin, and a super admin has full access to everything.

  • And then it's going to tell me what's my password?

  • And that's what you wrote inside your installation process.

  • So when he installed post breads, it told you to put a password inside there.

  • So we're gonna put inside here.

  • Okay, so I'm inside my database, So let's get a run through the commands that was talking about when I do slash out it is going to show me all of my databases.

  • So, for example, if it's still look confusing, essentially all of these little things that you see over here on the side is representing each of these databases.

  • Okay, So once I have this thing down, I could do control, See, to get out of this really quick, okay?

  • And then inside here, I'm going to see that have jwt off.

  • So I'm gonna move inside that database, so I'm gonna say slash See dont off now, as you can see here It's saying that you're connected to the database.

  • Jie deputy off as user pulls grass, Okay?

  • And then I can look at all the tables that's inside there by simply saying slash duty.

  • So in this case, this has a single user table.

  • Be awesome.

  • So, no, we're going to make art only database.

  • So I'm gonna go inside here.

  • I'm gonna grab this command, and I'm gonna put it right there and check this out.

  • I want to say you to be straight or a very database.

  • And then once we have that down, we could do slash help.

  • I can see right there that we have indeed add it to our database or to our post press.

  • I'm gonna do control, see again to get out of here, and then I'm going to move inside there, so slash See into referred to d'oh so you could see it doesn't seems like process.

  • And now I'm gonna run slash e t to see what or not we have any tables you can see here Says did not find any relations.

  • So now we take this thing right here, and then we put it right there.

  • Okay, so awesome.

  • So we create a table and now I do slash D t You can see that.

  • Indeed.

  • We have created a table called to d'oh.

  • Now I think it's also worth mentioning that you don't have to call this to do idea and also called this tea ideas wall.

  • So I'm just gonna show you this command later, But essentially, it's going to get all of my to do lose.

  • See, that right here is what we define our scheme of us to do I d and description.

  • And, like I said again, doesn't have to be to do I d.

  • I'm just being explicit.

  • Some people just like to say t i d or you could do whatever you want with that.

  • Okay, so in the next section, we're going to connect our DD baseball for server.

  • Okay, so let's start connecting everything together, so connecting like our database over server is really easy when we use the PJ library.

  • So what?

  • I'm gonna go is create a file called Bebe.

  • That Yes, and this is going to configured how we're going to connect to our database.

  • So I'm gonna say con school required PG library.

  • Remember?

  • We install the BG Library and Dark pool.

  • And now we can instance this fold.

  • I seem concert pool because I'm your poor, and now we can set up our configurations inside here.

  • So what's inside?

  • We have the first specify our user.

  • So in this case, we're gonna be using the post Press user.

  • Then we have to define a passport as well.

  • It's okay.

  • Teach out to choose mine.

  • You also have to say what the host is, which is gonna be local hosts.

  • And then we're also going to specify airport.

  • We're just going to I'm likely run import 5432 and then, which is also very important.

  • We also have to specify the database, which is going to be perm to Dio because, as you can see, here, we created this Davies called parent to do, and that's the database we're going to be using.

  • So also mets all it takes to connect to our database.

  • So I'm just going to export this guy.

  • So that module that exports and then pull Okay, so since that's all set up for us, I'm going to go back into our index that Yes, and I'm going to require that.

  • So by using the pool, we can run queries with post press.

  • Oh, my God, what's happening?

  • Dot slash DV There you go.

  • Okay.

  • And just kind of give us a heads up.

  • I'm just going to start writing the routes that we're going to be working with with this pool query stuff.

  • So the 1st 1 is that we want to create each d'oh next one.

  • I want to get all two DUIs get paid to d'oh!

  • Update eight to Dio!

  • And finally, I want to delete eight to d'oh!

  • So we're gonna work on each of these routes and we're going to be using this new connection and we have over here to run queries with her post press.

  • So I'll see you then.

  • All right, so let's start building some routes.

  • So right off the bat, we're going to start with creepy to d'oh.

  • Let's do this.

  • We're going to see after that post.

  • The reason is gonna be post is because we're adding data and I'm going t o leave Israel s deduce.

  • Okay.

  • And I'm going to run three reckless rez which represents requests from the client site and response.

  • We're going to send back to climb, and then I'm going to use a sink.

  • Now the great thing about a sync by using this were allowed to get these really cool tools that makes basic goodness requests easy.

  • So, for example, anytime we're creating data over trying to get data, it's going to take some time.

  • So a Singh provides the suddenly call await, which waits for the function to complete before it continues.

  • Okay, so you ever see that?

  • Pretty soon.

  • So then we also have tried catch, which makes our air handling so much more easier the reason for this because it's going to run a regular code, and any time it finds the air, it's going to catch it, and it's going to throw it out.

  • And this is how our basic air handling is going to be done.

  • Okay, so now that's done inside here.

  • I need to be able to get data from the client side to determine what exactly I'm going toe.

  • So remember how I said we need to do something?

  • Call Express that Jason.

  • So I just kind of had to comment over here that's going to let us add request that body so By using this, we can access this object right there.

  • And if you don't know what it is, I can just constant log day.

  • I shouldn't give you guys a heads up, but I am going to be using Postman.

  • Postman is great when it comes to wanting to test your applications or your wrestle ap eyes.

  • So in this case, I'm going to create something new.

  • You see right off here that we have all these different types of HDP that we can use.

  • So in this case, we're going to be using post.

  • And I also need to specify that I want to hit the slash deduce routes.

  • So let me do this really quick.

  • So I'm going to say http slash slash local hosts 5000 and in slash studios.

  • Okay.

  • And now remember how we can access his request that body.

  • So when you go inside the body right here, I'm gonna see raw.

  • I'm gonna specified spooning with Jason.

  • Then I'm gonna create a G, some data.

  • So in this case, remember working description.

  • So I'm just gonna see description is I need to clean my room.

  • It's no if I click send, we look inside here.

  • You could see indeed, it pops up right there.

  • Description.

  • I need to clean my room.

  • And this is exactly the data that we're going to use to save it within our database.

  • Okay, so hopefully that clears things up.

  • So remember, we have this description that I'm gonna be using, so going to d structure that he was a constant description in a request.

  • That body.

  • Okay, so time for some actual queries.

  • So I'm gonna see Constance knew, too.

  • And then I'm going to see a wait.

  • Cool that query.

  • So remember that pulls what we just created right there.

  • And now we're gonna start running some queries.

  • So in order for this thing to work or to add data, we have to use the answer into command.

  • So insert into And then after that, we have to specify which table we're trying to insert into.

  • We're just going to be too d'oh.

  • And then we have to specify what type of column are trying to add data into.

  • So in this case, we have a simple description, and then we have to specify the values of that, and this is going to look a little bit weird at first, but we're gonna have something called dollar sign one.

  • So what is this?

  • This is going to be a placeholder or essentially going to be a variable that's going to specify this description.

  • So we're gonna have the second argument.

  • Side is query, which is going to define this dollar sign one.

  • So remember how we have a description which has come from a client side.

  • I'm gonna put it right inside here.

  • No, our description is going to be the value of this dollar sign one.

  • Okay, so if it's still little bit confusing, don't worry about it.

  • Let me just bristol juice in this.

  • I'll explain it again.

  • Okay, So I'm gonna do this really quick, And now I'm going to open my postman one more time, and I'm gonna try to hit it.

  • You see, we had a status of 200.

  • And don't be scared, but you're gonna see a lot of gibberish.

  • Do you see all of these things?

  • But this indicates that we have done something successful.

  • So we look inside our database and I see select all from to do.

  • Like I said again, you don't have to know this command yet.

  • I'm gonna explain it later.

  • You could see that indeed, that we have added that data insider database.

  • So pretty cool.

  • And look, you don't have to sit as dollar sign one that's just the PG library along us to add dynamic data.

  • We can actually just do it straight inside here.

  • So, for example, I could just say, like, insert into to d'oh because I'm trying to hit this column right there.

  • I also have to specify the values of this guy, and I'm going to say single quotes.

  • Let's just say hello, for example, and then that's all I could do.

  • You can see I answered the data, and if I decided to see what's inside there again, you could see it that I have added, Hello.

  • It's a nice and you also see that we're incrementally this thing 12 We didn't do that, but because remember, we set serial primary key is going to automatically increase it to ensure that we have uniqueness.

  • All right, so hopefully that made more sense is could see here that this dollar someone is just going to allow us to put in some variables of what we're trying to babies so you can see that we have all of this ugly thing over here.

  • So we want to make sure we're returning back the data.

  • So what we have to dio is, say, returning, returning star.

  • So returning star issues whenever you're inserting data order, updating or deleting.

  • So any time you're doing these type of actions, you're going to return back the data.

  • So let me show you again.

  • I go inside here and I tried to hit this route.

  • You'll see we'll get something different.

  • Do you see this?

  • We have now all of this data, and you could see that this is the data that we just added inside there.

  • I need to clean my room to do idea three.

  • And we want to just hit this rose right there because we don't want to see all these other things.

  • So inside I'm just gonna say you to do that, Rose, and then I'm gonna hit the first.

  • So now I'm gonna hit it one more time.

  • So she changed it up a little bit, and this is good for us because we're really we're gonna in the next round.

  • We're just going to try to get these two DUIs.

  • So now we go to the bottom.

  • You can see we have something that's a lot more easier to read.

  • So awesome.

  • Okay, so we create our two.

  • D'oh!

  • Next, you want to see all our two DUIs, and this one's really easy.

  • And if you're going to a memorize it right off the bat So I'm gonna see up that get because we're just simply wanting to get beat up.

  • I'm going to see slash two DUIs and then I'm going to do the same process.

  • Requests that risk.

  • I'm gonna use this racing stuff if I catch so this is really my regular convention.

  • And I like doing also that.

  • Hear, hear that message.

  • And then inside here, what we're going to do is we're going to be saying sconce all two DUIs await is gonna take some time.

  • Pull that query.

  • I guess this select Remember, we use select Oh my God!

  • I could spell it.

  • Select all from two.

  • D'oh!

  • And that's all we have to dio.

  • Really?

  • So remember how I kept running this command just to see my produce?

  • This is exactly the same as that command.

  • So now I could save rest of Jason Walter Deuss, remember, it's gonna be in this row stuff.

  • The only reason why I don't have to see returning stars.

  • Because the purpose of select is to even give us the data back.

  • So we don't have to say returning star.

  • So let's check this thing out.

  • So I'm gonna go inside here, and I want to see all of my two DUIs, so I'm gonna make it get requests and check this out.

  • How cool is that?

  • So now we have all these different deduce that we just create it, and we could just spit it out by simply running this command.

  • All right, so pretty simple.

  • So the next step we're now wanting to still get to do so.

  • So we're gonna have this state, But we want to get a specific to d'oh.

  • So it's still gonna be after I get because we're getting data now I'm gonna say slash news and I'm going to also do colon I d.

  • So what is that?

  • They just finished this really quick.

  • Just the basic set up.

  • You try catch here council dot error.

  • Hear that message.

  • Okay, So what is this thing.

  • Essentially, this allows our are your cultivated out is it's gonna lower your l to be dynamic.

  • So we have access now to something called council dot log.

  • Do you request up?

  • Perhaps.

  • So whatever the client specifies in you're out, it's going to spit this out with the variable I d.

  • So the low confusing.

  • So let me show you what I mean.

  • So I'm gonna go back inside here.

  • You can see that we're gonna try to hit this route so I could see slash seduce, and then I can just write something random.

  • All indeed.

  • That's what I'm going to write.

  • Look inside here.

  • If I click enter, you can see that we have an i d off random.

  • And this is actually coming from this area right here.

  • You see, we specify I d I'll have to call it this.

  • I can just name it whatever I want.

  • And if I see of this and I enter it again, it's going to do the same exact process.

  • So subject random.

  • Okay, so hopefully that makes sense, because that's what we're gonna be using to specify what type of to do we want to get So you're gonna see later on.

  • We're going to specify as 123 you name it.

  • So let me just change his back to its regular form.

  • And, uh, yeah.

  • Okay.

  • So now what I'm gonna do is I'm gonna d structure this.

  • So const i d from request up four times.

  • And then now I'm going to try to get this idea so constant.

  • D'oh!

  • We're gonna see you wait, because it's going to take some time.

  • Well, that query now select.

  • Oh, from two.

  • D'oh!

  • Okay.

  • And now I'm gonna introduce a new player, which is called the Where Klaus and the Wear Clause specifies.

  • What type of to do we actually, we actually want.

  • Sorry about that.

  • What was that we want?

  • So in this case, I'm going to specify the column to do I d remember.

  • We named it inside database.

  • That s Q ball.

  • I'm gonna see what to do.

  • I d equals $2 sign and I'm going to specify it with the i d.

  • Reason why this is important.

  • It's because I can specify this ass deduce and I want to get the one.

  • So it's going to say select all seduce where the do I d equals to 12 or three.

  • So you'll see this in action real soon, And then I'm going to simply say wrestle Jason to dio that Rose.

  • And I'm gonna get the first item because we're just getting want to do.

  • All right, let's see that really quick.

  • So in this case, you can see that we have all our deduce right here, and I want to get number three.

  • So I You know what?

  • Let's do number four.

  • So am I sick?

  • You can see that we get our specific data.

  • It's a nice.

  • So by using the work loss, we can be specific on what we're trying to get.

  • Okay, Pretty simple.

  • And we're gonna work on the next round, which is going to update a todo.

  • This one is probably a little bit more complex from the rest, but still not as bad.

  • So sense for updating information.

  • I'm going to see at that.

  • Put, I'm going to special diet as two DUIs, and it's going to be I d.

  • So the reason I need to specify I d because I want to know what exactly, or what should you need to update.

  • Then I'm gonna run piecing so the regular stuff and then what I'm going to be doing inside here just really quick.

  • Okay, So what I'm gonna be doing inside here is I need to have two bigs.

  • Remember, we have access to the request the body to get information about the description that we're trying to add to a database.

  • And we also have across the Paramus to specify what type of to do we want.

  • So we're going to need both of them in order to update and explain why.

  • So we have I d over here.

  • Request up grams, and then we're gonna have const over here, which is going to be What is it yet?

  • Description West Stop body So awesome.

  • We're gonna be using these tools tow up to your information.

  • So here's how the crazy works.

  • I'm gonna see constant Update two D'oh!

  • And then I'm going to do a weight again.

  • Well, that query.

  • And now this is the cradle.

  • I'm going to run.

  • I'm gonna say update.

  • I have to do I have to run update and I have to specify the table.

  • So update introduce table, and then I have to run.

  • Set.

  • So what do I said?

  • I have to slip your description column.

  • Do whatever I specified, right?

  • Actually set the description to the description that specified inside.

  • And then I also have to specify where it's located at to see where it's a deal.

  • I d equals $2 sign too.

  • Okay, so this means look a little confusing.

  • But remember how I said these represent variables so we don't have to just $2 someone we could do a limit.

  • And most like you could even go up to, like, dollar signs 100 if you need thio.

  • Right.

  • But basically, these air just variable holders.

  • So all I have to do is go inside my second argument array, specify the first value, which is going to be description.

  • So this is representing this one right there.

  • And then I have to create a common right here and specify I d.

  • So this idea is coming from here, and it's going to represent this dollar sign too.

  • Okay?

  • And now I could just do Prescott, Jason, and I'm just gonna keep this simple.

  • I'm just going to say to do was updated.

  • Okay, so let's see how this is going to work.

  • Someone didn't go inside here.

  • I'm going to try to change.

  • I need to clean my car.

  • So let's go up here really quick and let's see.

  • Let's I need to clean my floor.

  • So now I have to change this the foot because I'm trying to update this.

  • And now if I click enter, hopefully it works because you have a status of 200 and indeed to do was updated.

  • So let's just double check to make sure did.

  • So.

  • If I go inside slash for look into the bottom.

  • Oops, I have to meet this to again request.

  • It does change.

  • So says I need to clean my floor so cool we're able to update our information.

  • And if you're still confused like I said again, I'm going to do a quick review over all the queries we just did.

  • And finally, we have deleted to do, which is really easy.

  • Exactly.

  • Kind of like the get requests.

  • So what we're gonna be doing is up, Doc.

  • Delete is Medellin data slash seduce and all.

  • We could do a specified the idee in the regular process, But trust that rose catch.

  • That's all done and ready to go.

  • We don't have that data to a delete.

  • So all we have to do is specify what is suck.

  • We want to delete.

  • Hey!

  • And inside there were going to say constant elite to d'oh and we're gonna do the same process away.

  • Pool that query, and I'm going to say delete from So I'm gonna run this command delete from, and we've to specify and the two DUIs table and always the do life is say, where it's located at.

  • So we're going to do I d equals $2.

  • Say, like, and that is just going to be as you guessed it idea.

  • And then we're just going to do another rest out, Jason, and just stay to do was deleted.

  • So congratulations.

  • Well, actually, no.

  • We can't say that yet until we test this out.

  • So let's make sure that we can actually delete this one right here.

  • So in this case, I want delete that fake sample that created over here.

  • So hello.

  • So I'm going to say slashed to specify it's going to be a delete request because remember, I specified asked elite now if I click, enter Judea was deleted.

  • And let's make sure it does get to leave.

  • It hopes it could get requests.

  • Check this off.

  • It was So leave it.

  • Hey, so congratulations, you officially created a recipe of Post Press.

  • So in the next section, I'm just gonna do a quick overview of the quarries we did so you can have a better picture of what happened.

  • I'll see you then.

  • All right, so congratulations.

  • We're building a wrestle a p I with post dress.

  • So I'm just gonna give you guys a quick review because I want this really in green in your mind.

  • So as you can see inside here, we had a basic server that we set up, and then we do something called database that s Q ball.

  • So this means more visually pleasing for us to write our commands again.

  • You don't have to do this way.

  • You could just put directly inside the command line.

  • So we did was create table her to do.

  • And then we created a whole sorry not create table.

  • We created a database called Perched You.

  • And then we created a table within that database called to d'oh, and we had to find two things.

  • The site there, the 1st 1 to find Westie Description, which was given a Max character of 255.

  • And then we set something called to do I D.

  • The primary key.

  • And the reason why it's so important is because of one unsure uniqueness between all our other two DUIs.

  • Because if you want to delete, update or get a specific to Dio, we will have to reference something that distinguishes the rest of the other two DUIs, which, in this case, to do I D.

  • And then you see a primary key indicates that this to do I D is what makes it unique.

  • And then we have the serial function, which automatically increases the primary key to ensure that's unique.

  • As you can see inside here, that's what happened 1 to 2.

  • Now, in order to connect to it, it was as easy as taking the library so required PG, that pool, and then we just have to configure where and how we were going to connect to it.

  • In this case, we have to specify the user the password.

  • The host, which is local host because is running on our local machine our port by default.

  • Poster runs on 4432 and then our database, which was per two D'oh!

  • So as you can see, the reason we connected to perch induce because that's what we specified.

  • Okay, so now when we go to index century, yes, we start to create some routes.

  • So whenever you're creating something inside Post Press, you have to use the insert into command.

  • Okay, so the insert into command specifies the table that you want to insert something in and the column, which is going to be description, and then you have to enter in what that value of this description is going to be.

  • In this case, we had dollar signs, one which was really strange for a lot of people who just started.

  • But essentially, this is just a simple place holder, and this value is going to be specified in the second argument array, which is going to be description.

  • So this description is going to represent this dollar sign one over there, okay.

  • And then, uh, and also it's worth mentioning that all of these different commands that you see here, these queries them having over here can just simply be run inside a command line himself.

  • And also we have returning start because we were adding data.

  • So we want to get back that date again.

  • So any time you're trying to insert or you're trying to update or delete, you have to use returning star to show what exactly?

  • Using.

  • And then we had to do wrestle jayson dot roast because that's where the data is located at Finally inside here.

  • We just had to do select all from studios, and this allows us to get all the to do from that table right there.

  • And as you can see here, you don't have to specify stars.

  • I don't know if I was specific on this, but it doesn't have to always be select Star Star is just simply there to say that we want to get everything.

  • So if I go to my command line and I see select and so star I could say description from to d'oh, just get description so I could be a specific on what I'm trying to get.

  • So instead of actually trying to pass everything to decline site, I could just minimize that just passed.

  • But I really need to pass over to the client side and then we just press that Jason that data.

  • And inside here we introduce a new player called Aware Clause in the world.

  • Clause allows us to be more specific on what we're trying to.

  • D'oh.

  • So in this case, remember we're trying to get all traduced.

  • But on Lee were the key to do I d egos to what we specified in the client side.

  • So we say, where specify the column, and then the number equals two.

  • Then we worked an update, which was a tiny bit more complex, but it was still nice and easy to work with.

  • So we have to get the update command, specify the table, and then we have to use Set described the calling that we were trying to change.

  • So we set that equal to the description to find and the client side.

  • And then we have to specify where that to do we want updated was going to be located at, so we have to see where to do.

  • I d equals to whatever you specified insight there.

  • Okay.

  • And already you could say we had dollar signs.

  • $1 sign too.

  • You could go up to any dollars Things you want to.

  • It's just that inside your Ray, you just have to specify inside there.

  • So I added a dollar sign.

  • Three.

  • I will have to add it inside this arrays.

  • Well, what That equals d'oh!

  • And finally delete, which was really easy.

  • Always do was specified.

  • Delete from command, specify the table and see where it was located at.

  • Okay, so we use that were claws again.

  • So pretty simple stuff.

  • So congratulations.

  • So in the next section, we are going to start creating our client's side.

  • So just so you guys can see I'm just going to create a you turned over here and then I'm going to see MPX create react up, and I'm going to find it as client.

  • Okay, so after this thing, finish loading, we'll just start building our application, right?

  • So I can see my client's side has finished loading.

  • So before I even like to jump into clean this thing up, I just want to show you guys quickly of this diagram again and the different components that were going to be working with.

  • So let me just kind of zoom in a little bit So remember, we're going to be having three components to this friend.

  • So we're gonna have 1st 8 input component.

  • Then we're gonna have a components going to show all the two DUIs.

  • And unless we're gonna have a component that's going to open our edit motile.

  • Okay, so let's get started.

  • So I'm gonna go back inside here, and I'm just gonna playing some things up so we don't really need these anymore.

  • Well, we're gonna need them eventually, but let's just focus on the client side.

  • So I'm gonna go inside here, and I'm just going to clean some things that we don't need.

  • So in this case, we don't need this.

  • You also don't need this local SPG.

  • I'm also gonna get rid of the service, stood up tests, All right?

  • And then we're gonna go to index that gs clean all these things out really quick, right along with several worker.

  • I don't need that anymore.

  • And then I'm gonna goto dot g s.

  • And I'm just going to get rid of this local stuff so we don't have any errors, and I'm just going to take in the fragment, all right?

  • And I'm just gonna clean this all out.

  • We don't need these things anymore.

  • All right, We're gonna put fragment side there, and here we go.

  • And just to make it even better, we're just going to create a new folder called Components.

  • So we're gonna talk about the street components we just did.

  • So we're gonna do a new file, remember?

  • We're gonna have a search input, So input to Dio j s.

  • Then I'm gonna make another component which is going to Les all over to do cogs.

  • And then finally, I'm going to make a new file.

  • That's goingto have you had it to do?

  • That's pretty much the setup for components right now.

  • And also, we are going to be using bootstrap for So let me kind of get that set up for you guys as well.

  • So go inside here we strive for.

  • Then we're just gonna open this thing up and just go down here, take the CSS, and we're gonna put it inside our public index HTML.

  • So I'm gonna just put my leak only right here if you want to.

  • You can just get rid of all these comments.

  • They're not going to help us, really.

  • and finally, we are going to be using Immortal.

  • So I'm gonna take this on this data right here, and then I'm gonna put it right there.

  • Which, Yeah, right there.

  • I'm gonna put it near the body.

  • Okay.

  • So pretty neat.

  • Okay, so that's pretty much for set up.

  • So the next section, we're going to start building the input to you already, so let's get started.

  • So I already went to my client folder and ended MPM start to get everything ready.

  • So let's go inside our input to do and let's start setting some things up.

  • So I'm going to start seeing import react from yet, and then I'm gonna make a simple component just to get enough on the board.

  • I'm going to return a simple each one that's going to be input to d'oh!

  • And I'm going to export default this Yeah, I'm going to require it within my thought gs.

  • So let's go inside here.

  • And I'm just going to add a comment that's going to save components.

  • And it's going to say import input to do from about slosh components slush input to d'oh!

  • All right.

  • And now I'm just gonna put it right there, Right.

  • And now, if I looking over here, you'll see that have been put to do.

  • And it's a little bit too close on the side.

  • So I'm going to make sure that I space this thing out with a container.

  • Hey, I'm here and I'm gonna put it.

  • Oh, no, not there.

  • We'll put it right there.

  • And it should be a lot more species, so yeah, it's a little bit better, and I kind of want to make that in the middle.

  • So let's go into it.

  • But to do.

  • And now we can start doing some real things.

  • I'm gonna make a fragment.

  • And I've been from a regular right here, and I'm gonna put my each one as pern to do unless okay, and I'm gonna add a class name of tech center.

  • And I'm also going to add a margin top of five because it s you couldn't see.

  • It was a little bit too close.

  • So it looks nice for us.

  • And the last thing we need to do next is that we need to create a form because we are going to submit something new.

  • So I'm gonna create a form over here.

  • You don't need this action.

  • And I'm going to have input right here.

  • It was a text.

  • Keep it like that.

  • And then I'm going to have a button that's going to see at Let's see how that looks like pretty ugly so we can make that look a little bit better.

  • So class name.

  • I'm gonna have to beat you.

  • Will not be thine in there, but I'm gonna save for control for here.

  • That should make it a little bit better.

  • Okay?

  • And right on the bath.

  • You see, it's kind of knocking the hat out, so let's just kind of decorate that as well.

  • So I'm just gonna stay close to me, bt NPT and success.

  • And then after that, I'm gonna add a deflects, because this thing goes 100%.

  • I want them to be together.

  • How you can see now it's going to be put together.

  • Awesome.

  • And it's still a little bit tight, so I guess I'm gonna have a margin top five there as well.

  • I'm just really abusing this margin.

  • Top five.

  • Yeah, it looks a lot better.

  • Okay, so now it's time for us to react.

  • If I the same.

  • You want to start containing our state within this.

  • So I am going to be easy react, Cox Somebody use new state and it's right here.

  • I'm gonna put on the top, So I'm gonna stay constant, and I'm going to say, Let's see, let's call description and then we're gonna say set description and I'm gonna set it to your state and at a depot value off empty string.

  • Now, if you don't understand this, basically, this is our state, and this right here is the only way to change the state.

  • And then we have a new state to show our default value.

  • Now, I'm gonna go to my input when it's that the value to that steep that I have worked there just description just to prove my point that this is our deep over there, I'm just gonna have something like for example, Hello.

  • So now if you look inside there, you'll see by default we have hello inside there.

  • Okay?

  • We can't change it because we don't have a Longines yet.

  • You can open this thing up and what I'm going to do next is that I want to changed or up.

  • Deep description So I'm gonna see unchanged, and I'm gonna use you for event.

  • And it's going to do set description to either targets.

  • It's gonna target whatever is in the input, and it's going to get a result the value of it.

  • Okay, you got target done.

  • Now, if I just type inside this thing, just average and values, it's going to update, and we want to get rid of the hello because we don't start back.

  • Okay, So pretty neat.

  • So we have this wreck stuff set up next, we want to be able to submit our forms to send data out.

  • How do we do this?

  • Let's create a function is gonna call consummate form.

  • So I'm just gonna No, Yeah, I'll just make this air function, and hi there.

  • I'm gonna use my try catch again.

  • So I gotta use that.

  • He sinks stuff, and I'm gonna set this to care.

  • So, Consul, thought care error that message, and I'm gonna put it inside here because it's going to send an event, and we don't want this thing to refresh.

  • So I'm gonna see you that prevent default.

  • Now, inside here is where we're gonna sta

Hey, this is Henry.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it