WEBVTT 00:01.960 --> 00:07.750 So let's get started improving this get widget function in models don't go, but before we do that, 00:07.750 --> 00:11.250 I have a little thing I want to change here just for consistency. 00:12.400 --> 00:19.420 Back up at the very top, I have widget I.D. in the order type with a lowercase and that's not good 00:19.420 --> 00:20.020 practice. 00:20.020 --> 00:26.530 When you have an ID go really likes things to be with a capital I and a capital D so I did it there 00:26.570 --> 00:28.620 and let's see if I did it anywhere else. 00:31.180 --> 00:38.230 Transaction status that should be in case, and this is just a just a convention that you'll find in 00:38.230 --> 00:40.390 most go programming shops. 00:41.140 --> 00:42.290 OK, so that works better. 00:42.700 --> 00:43.870 So those are all fixed up. 00:43.900 --> 00:47.020 Now, what do I want to select from my database right now? 00:47.020 --> 00:50.520 I'm saying select ID and name from widgets, and we want more than that. 00:50.860 --> 00:52.480 So let's bring up our database again. 00:53.710 --> 00:54.910 Just look at the column names. 00:55.570 --> 01:05.800 So under widgets structure, I have already name, description, inventory level, so I'd name what 01:05.800 --> 01:10.930 I'm going to do is wrap this whole thing in back ticks just so I can put it on multiple lines so it's 01:10.930 --> 01:11.890 a little more readable. 01:12.400 --> 01:19.780 So I'll I'll say and I'll just put this right down here like that so it's more nicely formatted select. 01:19.780 --> 01:23.050 I'd name description. 01:25.060 --> 01:34.840 And let's go back and look at the column names, inventory level price in the entry level price and 01:34.840 --> 01:35.530 back again. 01:37.210 --> 01:45.520 Then I have image and created an updated I'll do it in that order image and on the next line created 01:47.140 --> 02:01.000 and updated that from intent that here widgets where the back ID equals the perfect. 02:01.390 --> 02:03.960 So now of course we're scanning more than just ID and names. 02:03.980 --> 02:05.320 We'll have to change this line. 02:10.930 --> 02:18.520 And what I'll do is just duplicate this a few times to save some typing so that my name, description 02:20.190 --> 02:28.570 and inventory level than price than image 02:31.660 --> 02:33.280 and we may as well get created a. 02:37.500 --> 02:38.400 And updated it. 02:40.590 --> 02:45.570 OK, now the only change I'm going to make here is there may be situations where we don't have an image. 02:46.170 --> 02:53.400 And what I could do is take advantage of the skill and all types that are built into our database environment 02:53.400 --> 02:54.240 or built in to go. 02:54.540 --> 02:56.830 But what I'll do instead is just coalesce. 02:57.780 --> 02:59.340 It just saves some programming. 02:59.820 --> 03:03.600 I'll take image if it has a value, otherwise put it in an empty string. 03:03.990 --> 03:10.200 OK, so that should get the necessary information from the database, which is a good start. 03:10.860 --> 03:14.710 Now what I want to do next is to modify this route. 03:14.730 --> 03:22.620 Let me go to rootstock, go modify this from charge wants to say widgets and then the idea of the widget. 03:23.010 --> 03:31.620 I can do that right now say slash widget slash and then the idea. 03:32.040 --> 03:38.190 OK, and just as we did on the back end, I can go to the handlers for this. 03:40.700 --> 03:43.100 And find the charge once handler. 03:45.960 --> 03:53.010 And get the ID right from the URL, so let's just copy and paste from our handlers API, let's copy 03:53.010 --> 03:56.170 these two lines and copy this one as well. 03:57.240 --> 04:06.570 Copy those and go back to our handlers and paste that right here and get rid of this widget bit. 04:09.150 --> 04:16.420 And we'll have to import these as Takio and see, and that should take care of the imports for us. 04:17.010 --> 04:24.060 So now when we come to this you URL, or does this handler charge once will grab the ID from the Eurail 04:24.060 --> 04:29.640 itself, convert it to an end color database function, and then we have our widget and we can pass 04:29.640 --> 04:31.430 that into the appropriate template. 04:31.440 --> 04:33.220 And this is actually pretty effective. 04:34.110 --> 04:40.710 So that means, of course, that I'll have to find my templates and I have an area somewhere. 04:40.980 --> 04:41.940 Let's see what that is. 04:43.260 --> 04:49.470 Safeness that there were just an unused important saving it got rid of it. 04:49.470 --> 04:51.010 The ID took care of that for me. 04:51.420 --> 05:01.620 Let's go back to our base layout and find the bi ones and change it to slash widget one because we only 05:01.620 --> 05:03.270 have one widget and that'll work for now. 05:03.750 --> 05:05.100 OK, so let's open our terminal. 05:06.060 --> 05:06.660 Look at this. 05:06.710 --> 05:07.260 Looks good. 05:07.430 --> 05:09.490 OK, everything seemed to compile properly. 05:10.080 --> 05:17.070 Let's go back to our front end on the web browser and I'll go to virtual terminal. 05:17.250 --> 05:22.590 OK, and now this product's menu should be updated to the correct world and it looks like it is. 05:22.620 --> 05:23.610 Let's see if we got it right. 05:24.720 --> 05:25.470 And there it is. 05:25.500 --> 05:31.710 OK, so it's displaying the necessary information now that price should have come from the actual price 05:31.710 --> 05:33.990 itself and so should this description. 05:34.020 --> 05:38.050 So if I actually go in and change the value in the database, this should now update. 05:38.700 --> 05:39.020 All right. 05:39.030 --> 05:39.840 This is a good start. 05:39.870 --> 05:41.340 Now, there's more things we want to do. 05:41.370 --> 05:46.290 For example, we don't want to have the image hardcoded and we actually want to take care of the writing 05:46.290 --> 05:47.910 of a transaction to the database. 05:48.060 --> 05:50.730 But we'll get started on that sort of thing in the next lecture.