1 00:00:00,510 --> 00:00:03,290 Now let's start reading from the database. 2 00:00:03,290 --> 00:00:05,511 First we'll find individual posts. 3 00:00:16,561 --> 00:00:19,620 Down here we have the get route found individual article. 4 00:00:20,870 --> 00:00:25,220 I've created a simple synchronous function called find that gets the ID 5 00:00:25,220 --> 00:00:29,770 from the route, and searches from the static articles. 6 00:00:29,770 --> 00:00:35,301 We can use SQLizer's find by ID method to find an article by the ID. 7 00:01:03,136 --> 00:01:07,911 Now we can get rid of the static articles at the top here and define function too. 8 00:01:16,491 --> 00:01:20,890 Next, let's work on getting all the articles back. 9 00:01:20,890 --> 00:01:25,291 In the get route for all of the articles we can use SQLizer's find all method. 10 00:01:57,121 --> 00:02:02,220 This will retrieve all of the articles, instead of a single article. 11 00:02:05,370 --> 00:02:06,480 Let's restart the server. 12 00:02:08,520 --> 00:02:12,410 This should now retrieve and show all of the blog posts. 13 00:02:14,900 --> 00:02:16,656 Let's create another blog post. 14 00:02:20,181 --> 00:02:25,201 My second Blog Post. 15 00:02:28,101 --> 00:02:29,320 Authored by me. 16 00:02:31,040 --> 00:02:36,020 And we can have any old text in this body here. 17 00:02:41,121 --> 00:02:43,060 It shows correctly. 18 00:02:43,060 --> 00:02:47,070 And when we go back to the article list page, we have a problem. 19 00:02:47,070 --> 00:02:50,280 The latest article appears last. 20 00:02:51,710 --> 00:02:52,771 We need to order the results. 21 00:02:58,851 --> 00:03:01,940 The findAll method can take an options object. 22 00:03:04,050 --> 00:03:09,340 Within that you can add any number of criteria to filter the results including 23 00:03:09,340 --> 00:03:14,450 order by to order a result set you use the order key 24 00:03:17,700 --> 00:03:19,680 with an array of a race. 25 00:03:21,890 --> 00:03:25,351 Each array includes the column you'd want to order by. 26 00:03:32,181 --> 00:03:36,580 And in which order, ascending or descending. 27 00:03:39,220 --> 00:03:43,440 It's an array of a race because you can order by multiple columns. 28 00:03:44,630 --> 00:03:49,300 In this case, it's only one, and it's in descending order. 29 00:03:52,100 --> 00:03:54,631 Let's reboot the server now, and go back to the list page. 30 00:04:00,401 --> 00:04:04,170 And now the articles are in the desired order. 31 00:04:04,170 --> 00:04:07,100 Next, let's work on updating models.