1
00:00:00,420 --> 00:00:06,300
In this video we are going to develop get all products method for product lambda microservices with

2
00:00:06,300 --> 00:00:10,580
using dynamo DB client object from the SDK libraries.

3
00:00:10,590 --> 00:00:12,180
So let's get started.

4
00:00:12,210 --> 00:00:17,850
Before start, I would like to show you where we are using commands and libraries.

5
00:00:17,850 --> 00:00:24,390
You can see that this is the SDK document for JavaScript three and we are using Dynamo DB Client Library

6
00:00:24,390 --> 00:00:30,480
and this video we will use second command because we are going to get all products from the Dynamo DB

7
00:00:30,480 --> 00:00:31,170
table.

8
00:00:31,170 --> 00:00:37,560
In that case we will use the can command and see the input parameters in here and we will set these

9
00:00:37,560 --> 00:00:40,920
kind of properties when interacting with second command.

10
00:00:41,130 --> 00:00:49,050
So please open the widget to your code and go to index js file in the last video we implement get product.

11
00:00:49,050 --> 00:00:51,570
This time we will implement get all products.

12
00:00:51,570 --> 00:00:57,450
So please scroll down and after the gate product method we will implement get all products in here.

13
00:00:57,480 --> 00:01:02,700
So for that purpose let me copy and paste and after that I will explain.

14
00:01:03,670 --> 00:01:10,780
These methods, you can see that this is the get all products that we are using the asynchronous method

15
00:01:10,780 --> 00:01:17,920
and in the first line we will log this operation and after that we are covering the three below to use

16
00:01:17,920 --> 00:01:18,670
the Amazon cloud.

17
00:01:19,090 --> 00:01:23,270
If there is an exception, we will see the logs on Amazon Cloud Logs.

18
00:01:23,290 --> 00:01:25,450
That's why we covered the case below.

19
00:01:25,450 --> 00:01:31,840
And we will prepare for the parameters and paste the parameters to the scan command and using the dynamic

20
00:01:31,840 --> 00:01:38,410
DB client, send operation and return back the items and we log the items and return back the items

21
00:01:38,410 --> 00:01:40,710
to the get all products method.

22
00:01:40,720 --> 00:01:43,800
So now let's import required statements.

23
00:01:43,810 --> 00:01:46,980
So for example, we will use dynamic DB client.

24
00:01:46,990 --> 00:01:49,210
We have already import this statement.

25
00:01:49,240 --> 00:01:55,030
You can come here and see at the beginning of the page we can see that we are using dynamic DB client

26
00:01:55,030 --> 00:01:59,170
object and we have import Marshall and Marshall operation.

27
00:01:59,230 --> 00:02:03,820
And if you scroll down this time we should import also a scan command.

28
00:02:03,850 --> 00:02:10,630
We can come here, click the control space and import or I'm going to copy the scan command and go on

29
00:02:10,630 --> 00:02:15,010
top of the page and put here comma and paste scan command.

30
00:02:15,010 --> 00:02:19,570
So that means we are using scan command from the client base dynamic DB library.

31
00:02:19,570 --> 00:02:23,410
So if you scroll down, you can see that this becomes green.

32
00:02:23,410 --> 00:02:25,570
That means we have import successfully.

33
00:02:25,930 --> 00:02:33,130
So in this stage I would like to emphasize that in here and also in the get product method, we are

34
00:02:33,130 --> 00:02:38,500
getting the table name from the process environment dynamo DB table variable.

35
00:02:38,500 --> 00:02:41,860
So that means this is the value comes from the environment.

36
00:02:41,860 --> 00:02:48,550
Variables of the lambda function is you remember that when we have defined the lambda function we basically

37
00:02:48,700 --> 00:02:53,020
create environment variables for the dynamo DB tables.

38
00:02:53,020 --> 00:02:58,900
You can check for the product function, go to configuration, go to environment variables, see that

39
00:02:58,900 --> 00:03:01,780
Dynamo DB table is here and value is a product.

40
00:03:01,780 --> 00:03:08,350
So that means we will scan and also get item command in here in the table name parameter comes from

41
00:03:08,350 --> 00:03:10,930
the lambda environment variables in here.

42
00:03:10,930 --> 00:03:18,310
That's why we use Dynamo DB table name and process dot and we provide to get environment variables from

43
00:03:18,310 --> 00:03:20,290
the lambda function and set in here.

44
00:03:20,320 --> 00:03:21,070
Okay.

45
00:03:21,220 --> 00:03:28,450
As you can see that we have develop get all products method and it is very similar to that product method.

46
00:03:28,450 --> 00:03:34,720
The only difference is the command that we use second command in here for getting all products.

47
00:03:34,720 --> 00:03:37,840
We use second command for getting one command.

48
00:03:37,840 --> 00:03:41,110
We use get item command with placing the parameters.

49
00:03:42,010 --> 00:03:43,510
So the idea is the same.

50
00:03:43,510 --> 00:03:51,280
You should think the Dynamo DB is a great resource and Dynamo DB exposing APIs for these kind of actions.

51
00:03:51,280 --> 00:03:58,540
And we call these APIs using the HDC package with to command objects and using the Dynamo DB client

52
00:03:58,540 --> 00:03:59,680
send method.

53
00:03:59,680 --> 00:04:00,880
So let's get started.

54
00:04:00,880 --> 00:04:02,470
Implement other methods.
