In this video, we are going to update an item into dynamic TV tables.
So we will implement these use case files, update item in dynamic TV table to perform update item command.
So in order to do that, please open the SDK documentation.
And if you search for the update item, if you go to command, you can see the example usage.
We will use update item command and to see input parameters.
It is a bit confusing if you open the update item command.
There are some properties that we can that we can use when updating an item.
So the important one is the table name and the key information.
In the key information, we should provide the ID as a number for the partition and primary key.
And after that we will use the update expression.
So in the update expression, we should give the which attribute we are going to update.
And after that we should give the values and the names from the expression attribute values.
Let me develop and show how we can update an existing item.
Are using the HDC.
So in order to do that, please open the Visual Studio code.
And in this file, as you can see that I have created update item JS file, that is implementation of
update item command.
So let me explain one by one.
But before explaining this file, I have also created a template JS file which including our template
code operations when it comes to interacting dynamic.
DB So as you can see that we have run method in here and in the drive look we will implement these dynamic
DB send operation according to command that we are going to implement.
So it is also taking parameters.
So we have also parameters object defined in here and these parameters attributes differentiate based
on the different commands.
So you can see that we have also import statement.
So I'm going to use this template for every command window and this time we are going to update item
and see that update item has also actual code operation in here.
We basically use dynamic DB client and we sent update item command with these parameters.
So first of all, we should import update item command and dynamic DB client object.
And after that we will prepare the parameters as per the documentation.
This is very important to set correct parameters.
So how we can define these parameters, of course we will check the SDK documentation.
And also I would like to show one more thing.
Maybe you remember in lecture 138, we have also performed the same action with using the same commands.
So if you can see that we are using the update item, select command specifying these attributes.
So I have specified exactly the same attributes which are the table name, key update, expression,
expression, attribute, values and so on.
So I will follow the same configuration into our update item JS and the parameters you can see find
in here.
So before starting these parameters, I would like to emphasize that we basically specifying table name
and key information, which is the ID of our product table and update in the update expression, we
have set the product name as any world and in the expression attribute values we have give the actual
value which be we would like to update these attribute name and we should also provide the string parameter
name as object format.
So this is very important to be in the same configuration, otherwise it gets lots of exception.
So please make sure that, for example, the attribute name should be product name.
The previous version we set the name and it is a resort keywords that is throwing an exception.
So that's why I have to change the attribute name as a product name.
For that purpose we have to write item again if you open the right item.
JS You can see that in the last video we have write item in this format.
So I changed the name as a product name and the ID could be only one.
Save this file and I'm going to write again this file.
But before that let's remove the old one for that purpose.
Go to Dynamic DB, explore items and delete this item.
And now I will come back to our record and continue with writing this item with the attribute name as
a product name.
So for that purpose, run the command node, write item, hit enter.
So this is write an item if you want the scan command, see that this time we have create an item with
the attribute name as a product name.
So if you come back to our update item operation, so make sure that your parameters is exactly same.
And if you come to command window and run the node update item JS file, hit the enter.
So this time we have update the product name as we expected.
And if you come back to the our DB console and run the scan command, see that this attribute value
is updated within the name.
So as you can see that we have successfully update our existing data.
In the next video we are going to getting an item with using the Dynamo DB SDK commands.