1
00:00:00,150 --> 00:00:07,320
In this video, we are going to use your ID library when creating product item into dynamic DB table.

2
00:00:07,410 --> 00:00:14,940
You can see the NPM package of the UUID library and if you scroll down we can see that how we can install

3
00:00:14,940 --> 00:00:22,500
UID, we can basically run the NPM, install UUID and see that this is very basic usage.

4
00:00:22,500 --> 00:00:29,820
We can import version four and we can use this function to generate this kind of data.

5
00:00:30,090 --> 00:00:39,630
And let's get started to implement these UID into our application if you copy this slide and come to

6
00:00:39,630 --> 00:00:41,490
our application.

7
00:00:41,490 --> 00:00:53,520
So basically please locate the required folder and we are going to install an EVE package which is the

8
00:00:53,550 --> 00:00:54,510
UID.

9
00:00:54,540 --> 00:00:59,460
Please run this command into the correct folder structure and hit enter.

10
00:00:59,490 --> 00:01:06,030
This will be downloaded are required UID library and you can verify from the package JSON file if you

11
00:01:06,030 --> 00:01:13,380
scroll on go to dependencies, see that we have successfully installed uid and it is time to use UID

12
00:01:13,380 --> 00:01:18,000
to generate naive product ID when creating a product.

13
00:01:18,000 --> 00:01:25,170
So come to the create product method and now I am going to update this line of operations.

14
00:01:25,170 --> 00:01:31,560
So instead of we are using the request, but I'm going to create a product request.

15
00:01:31,560 --> 00:01:33,960
So remove this line of code.

16
00:01:34,200 --> 00:01:35,400
Let me remove.

17
00:01:36,620 --> 00:01:39,310
And we are following the same discipline.

18
00:01:39,320 --> 00:01:43,420
Basically, we will get the event body information as a product request.

19
00:01:43,430 --> 00:01:51,590
But but this time I have generate a product ID from the UUID library and set the ID of the product request

20
00:01:51,590 --> 00:01:53,570
from newly generated ID.

21
00:01:53,600 --> 00:01:59,900
So that means we don't expect any ID information from the incoming body operation.

22
00:01:59,900 --> 00:02:07,010
So the idea is here, when request JSON comes to the lambda function, we have created a new product

23
00:02:07,010 --> 00:02:14,810
ID with using UID version for library and set the ID attribute of our incoming product request JSON

24
00:02:14,810 --> 00:02:15,440
object.

25
00:02:15,920 --> 00:02:22,460
So after that, we paste this object into the parameters of the product item command and this will be

26
00:02:22,460 --> 00:02:23,990
the our actual parameters.

27
00:02:23,990 --> 00:02:27,680
But please don't forget to replace these objects.

28
00:02:27,800 --> 00:02:32,690
As you can see that we have removed the request body and change the variable name as a product request.

29
00:02:32,690 --> 00:02:40,160
So that's why we should pass this JSON object into the item, not the request object I'm going to replace

30
00:02:40,160 --> 00:02:47,060
as a product request and now it is correct way to set the put item command parameters with table name

31
00:02:47,060 --> 00:02:54,380
and item item comes from the event body information and we set the product ID from using the UUID libraries.

32
00:02:54,650 --> 00:02:55,640
So that's all.

33
00:02:55,640 --> 00:03:00,920
In the next video, we will implement other current operations and please make sure that your create

34
00:03:00,980 --> 00:03:04,030
product method is exactly the same with this line of codes.
