Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CRUD operations using DynamoDB with expressjs (node js)

I am trying to create a route which will perform some CRUD operations on DynamoDB. At high level , it can be understood as :

  1. The node js server application is running .(i.e. command 'node server.js' is being triggered)
  2. The user uses POSTMAN of chrome browser to do route requests.
  3. The user does a GET request for 'http://localhost:8080/listtablesofdynamodb'.
  4. The specific route connected with this url gets hit which should do dynamodb specific activity. (like connecting to dynamodb ,fetching table names and showing it in callback method.)

the reason I am asking this question is because I could not find any relevant tutorial of how to do dynamodb activity by using express js of node. All I could find is console applications on aws website which seems not useful for me. Any kind of help is highly appreciated.

like image 594
Gaurav Shukla Avatar asked Oct 31 '22 06:10

Gaurav Shukla


1 Answers

Access key required

All you need to d is make a DynamoDB object to connect too

var ddb = require('dynamodb').ddb({ accessKeyId: '< your_access_key_id >', secretAccessKey: '< your_secret_access_key >' });

put this under your require statements, turn on your server. Then you can just fill out the routes to do the CRUD operations you need.

To test it use

ddb.listTables({}, function(err, res) {console.log(res);});

This will list all the tables in your db.

for full source check here

Best of luck

like image 164
Joe Lloyd Avatar answered Nov 15 '22 08:11

Joe Lloyd