In this video, we are going to be writing an item into the IMDB table.
So we are in the use case three red and white item in the table and we will use put item command in
order to writing item in the existing table.
So before we start, we should check the API SDK reference documentation.
So in here I'm going to search for the food item command, food item command.
If you click the food item command, you can see the details, how we can insert an item into Dynamo
DB table, we can see example usage code in here.
We should import IMDB client and put item command.
So put item command, get some input parameters.
In order to see the parameters, we can click the output item command input.
If you see the put item command properties, you can see there's lots of properties that we can provide.
So the table name is important, we should provide the table name and after that we should add an item
in here.
So item will be insert or dynamic DB table.
If you open the item, you can see the structure of the item, how we can provide these properties into
an item.
So let's implement this code in our visit to the code project.
In order to do that, please open the visual code.
And as you know that I'm going to follow the same folder, which is the all CRUD operations.
So now I have created a new JavaScript file, which is the right item that is in this file.
Basically, we will implement our actual logic to interact the Dynamo DB For that purpose, I have created
a run function and and we call these function in the same file.
And after that we have prepared the parameters to pasting the dynamic DB client object.
And also we need to import statement as well.
So let's start implementation.
Basically, I'm going to write this line of code to perform put data operation.
So if you remove the command part.
So basically as you can see that this time we are using to put item command with sending the Dynamo
DB client.
So we need to import put item command statement into our HDC packets.
So last thing is left for the parameters, how we can add parameters and create items into Dynamo DB
using the boot item command, we should provide the parameters in here.
So basically there are two main parameters when creating an item.
This is the table name and the item parameters.
So a table name is a product that we create in the last video, an item that is going to insert item
into our dynamic DB table.
We should provide the partition key, which is the ID and specify the number format.
And after that I have several attributes that you can add additional attributes in this line of code.
I'm going to add a name and the name is a string and I'm going to add the iPhone X product into number
001.
So here you can find the parameters and this parameter definition to the boot item command and dynamically
be client object sent to our item command to dynamic DB to insert an item.
So please save this file and open the terminal, go to the same directory and run the node command for
the writing and item so not v.
We are going to run node command with the right item.
JS Hit the enter.
So you can see that we have successfully get a 200 response.
That means we have added in inserted successfully item into dynamic TV.
To verify that, please open the.
Edwards management console.
Go to product table.
Click to explore table items.
Run the scan command and see that we have successfully ad ID one and the name is a phone x.
Since we have defined as a number even we give the 001, it takes the one to the ID as a part of product
table.
So as you can see that we have successfully write item in order in the table.
In the next video we are going to read data from this table.