In this video we are going to create Dynamo DB Klein Node.js Modal for connecting to Dynamo DB.
This section will interact with Dynamic DB.
For all these interactions, we need to connect Dynamo DB.
For that purpose, we should establish Dynamo DB client object instead of creating new client for every
SDK request.
It is best practice to create Node.js module and use this model for every particular SDK commands.
So we are going to create a new folder structure and we are going to create a Node.js module with the
file name of the DB client, which is the Dynamo DB client object.
So let's get started.
If you open the widget to the code, as you can see, I have create a separate lecture folder and create
a DB client JS file, which will be the AH Node.js module that provides to connect Dynamo DB.
And we will create a Dynamo DB client object in this module.
So for that purpose, let me create first and I will explain after that.
So basically we will use these codes when creating Dynamo DB Client object.
Cost the DB client and ne dynamic DB client object and we are placing the region in formation and after
that we are exporting this dynamo DB client object in order to use one interacting dynamo DB from other
models.
So this is the our main code, but there there are some missing parts.
Basically we should add required import statement for Dynamo DB client because this comes from the SDK
package.
For that purpose you can come here and see there is no suggestion, but I know that we should import
required statement which is the Dynamo DB client dynamo DB package including the Dynamo DB client object
from this HC package.
So this is important that we are going to use dynamo DB client object when interacting Dynamo DB.
So that's why we have imported this statement.
But one more thing.
We should provide the region information.
This is also important client object required for the region information.
If you open the management console and come here, if you expand this section as you can see that I
am using us is to you can check from your console and you can set your region information according
to that, come back to our code window.
So basically I'm going to put region variable in here and set the US ista.
So so please save this file and finalize our Node.js module, which is the Dynamo DB client.
As you can see that we have created Node.js module for Dynamo DB connections with creating any instance
of Dynamo DB Client Object.
This client object will use every interaction with our SDK example.
Now we are ready for the all of our use cases which use cases we will create and using the tables,
reading and writing, single item reading, writing batch items, creating and scanning on dynamo DB
table and perform the particle operations.