1 00:00:00,180 --> 00:00:01,013 ‫So let's have a look 2 00:00:01,013 --> 00:00:03,260 ‫at these data API calls we can do. 3 00:00:03,260 --> 00:00:05,670 ‫So, if I go on my table, as we can see right now, 4 00:00:05,670 --> 00:00:08,420 ‫we're in the 'Scan' and we can select a table, 5 00:00:08,420 --> 00:00:09,600 ‫and then we click on 'Run'. 6 00:00:09,600 --> 00:00:11,740 ‫So, 'Scan' is going to scan the entire table 7 00:00:11,740 --> 00:00:14,930 ‫and, obviously, going to return many items to us. 8 00:00:14,930 --> 00:00:16,613 ‫If we wanted to create an item, 9 00:00:16,613 --> 00:00:18,810 ‫what we could do is specific user ID, 10 00:00:18,810 --> 00:00:20,900 ‫so Alice, four, five, six. 11 00:00:20,900 --> 00:00:22,780 ‫Then, we specify a timestamp, 12 00:00:22,780 --> 00:00:25,410 ‫so let me just do this one very quickly. 13 00:00:25,410 --> 00:00:26,340 ‫And then, T 14 00:00:29,830 --> 00:00:32,440 ‫zero five, zero six, and your zero. 15 00:00:32,440 --> 00:00:34,080 ‫Here we go. 16 00:00:34,080 --> 00:00:37,363 ‫Okay, and then some contents for it. 17 00:00:39,370 --> 00:00:41,840 ‫Alice blog, okay. 18 00:00:41,840 --> 00:00:44,000 ‫Now, let's create this item. 19 00:00:44,000 --> 00:00:45,730 ‫So, this was a put item. 20 00:00:45,730 --> 00:00:49,490 ‫Why, because we have sent a new item into DynamoDB, 21 00:00:49,490 --> 00:00:51,300 ‫and we specified user id post timestamp, 22 00:00:51,300 --> 00:00:53,340 ‫and this was new, so it got created. 23 00:00:53,340 --> 00:00:55,220 ‫If you want to look at update item, 24 00:00:55,220 --> 00:00:57,920 ‫what I can do is 'Actions' and then 'Edits'. 25 00:00:57,920 --> 00:01:00,040 ‫And then, we'll just edit one specific attribute, 26 00:01:00,040 --> 00:01:02,920 ‫so I did Alice blog edited, 27 00:01:02,920 --> 00:01:04,830 ‫and click on save change and behind the scenes, 28 00:01:04,830 --> 00:01:08,380 ‫this is going to do an updates item API call. 29 00:01:08,380 --> 00:01:10,940 ‫So, we have seen updates. 30 00:01:10,940 --> 00:01:11,860 ‫Now let's look at gets, 31 00:01:11,860 --> 00:01:14,500 ‫so if I click on this one, for example, 32 00:01:14,500 --> 00:01:15,880 ‫and I will go into the 'Item editor'. 33 00:01:15,880 --> 00:01:17,930 ‫Well, behind the scenes, by clicking on this row, 34 00:01:17,930 --> 00:01:21,080 ‫on this item, I was able to retrieve the content 35 00:01:21,080 --> 00:01:24,120 ‫of this item and so this was a get_item that was done. 36 00:01:24,120 --> 00:01:25,440 ‫So, this is good. 37 00:01:25,440 --> 00:01:27,740 ‫Now, we can do obviously batch actions, 38 00:01:27,740 --> 00:01:30,220 ‫so we can do 'Actions' and then 'Delete Items', 39 00:01:30,220 --> 00:01:31,710 ‫which should be a batch delete item. 40 00:01:31,710 --> 00:01:34,000 ‫Okay, so batch writes and then batch deletes. 41 00:01:34,000 --> 00:01:36,220 ‫But, if you wanted to delete everything in the table, 42 00:01:36,220 --> 00:01:38,340 ‫you could do 'Scan' and a batch delete, 43 00:01:38,340 --> 00:01:39,840 ‫but this would not be very efficient. 44 00:01:39,840 --> 00:01:43,320 ‫The other way to do it would be to simply drop the table, 45 00:01:43,320 --> 00:01:44,430 ‫and be done. 46 00:01:44,430 --> 00:01:46,990 ‫Now, finally, let's have a look at 'Scan' and 'Query'. 47 00:01:46,990 --> 00:01:50,480 ‫So, scan really gives you all the tables you have, 48 00:01:50,480 --> 00:01:52,160 ‫and then you can apply a filter if you wanted it to, 49 00:01:52,160 --> 00:01:54,300 ‫but this is done client side for this filter, 50 00:01:54,300 --> 00:01:56,610 ‫so this will be filtered in your web browser, 51 00:01:56,610 --> 00:01:58,600 ‫not in DynamoDB directly. 52 00:01:58,600 --> 00:02:00,110 ‫Or, you can do a query. 53 00:02:00,110 --> 00:02:02,650 ‫And, a query is very helpful because we can specify 54 00:02:02,650 --> 00:02:03,580 ‫a specific user ID. 55 00:02:03,580 --> 00:02:06,040 ‫For example, John, one, two, three, 56 00:02:06,040 --> 00:02:07,260 ‫and then click on 'Run'. 57 00:02:07,260 --> 00:02:10,300 ‫And, this gives us all the items of John one, two, three. 58 00:02:10,300 --> 00:02:14,810 ‫But, also, we could have a query and specify a condition 59 00:02:14,810 --> 00:02:17,810 ‫on the post timestamp, which is a sort key. 60 00:02:17,810 --> 00:02:21,140 ‫So we can have equal to, less than equal to, 61 00:02:21,140 --> 00:02:23,350 ‫greater than, between, and begins with. 62 00:02:23,350 --> 00:02:28,310 ‫So, if you want to know all the posts after, 63 00:02:28,310 --> 00:02:31,380 ‫say 2021-11, 64 00:02:31,380 --> 00:02:32,580 ‫and click on 'Run', 65 00:02:32,580 --> 00:02:34,680 ‫we will only get one return item. 66 00:02:34,680 --> 00:02:39,680 ‫But, then, if we do 21, 2021-09, we get two items back. 67 00:02:39,750 --> 00:02:43,840 ‫So, as we can see, the query here is only done on user ID 68 00:02:43,840 --> 00:02:44,880 ‫and post timestamp. 69 00:02:44,880 --> 00:02:45,870 ‫We don't have to, 70 00:02:45,870 --> 00:02:48,470 ‫we cannot query on the content or search from the content. 71 00:02:48,470 --> 00:02:51,530 ‫We could filter on the content if we wanted to, afterwards, 72 00:02:51,530 --> 00:02:53,430 ‫but this will be done client side. 73 00:02:53,430 --> 00:02:57,160 ‫So, this really shows you the power of using partition keys, 74 00:02:57,160 --> 00:03:00,800 ‫such as a hash key and a sort key, okay? 75 00:03:00,800 --> 00:03:03,990 ‫So that's it, we've seen all the APIs of DynamoDB. 76 00:03:03,990 --> 00:03:06,700 ‫Now, let's just do a scan and retrieve all the data. 77 00:03:06,700 --> 00:03:08,140 ‫So, I hope you liked this lecture 78 00:03:08,140 --> 00:03:10,090 ‫and I will see you in the next lecture.