How to get the result of describeTable amazon dynamoDB method in Node.js? -


In my application I am using Node.js with Amazon Web Service dynamoDB.I already created a table and The item is inserted on that.Now I want to displayTable. How do I display the item count of my table using what I can try under the code, but it does not work. AWS = requires ('AWS-SDK'); AWS.config.update ({accessKeyId: '****', secretAccessKey: '****', area: 'us-east-1'}); Var svc = new AWS.DynamoDB (); ! Svc.client.describeTable ({TableName: "user"}, function (hey, result) {if (mistake) {console.log ('result' + [ITEMCOUNT] result); console.log ('success'); } Else {console.log ("fault is" + err);}});

The immediate answer to your question is that you will need to use the result. . The result of the jumpout Your callback function includes the IMAM account. However keep in mind that this count has not been updated in real time and can not show the status of recently inserted or removed in the table. If you want to count the current item, you need to scan the table and use the property to get the number of scanned items. With this type of scanning, all your provisioning capacity can be consumed for the table, so if it is a requirement, then make sure that with the other operations running on the table at the same time, the need to compute the need for recent item calculation Please.

Here is a sample nodes. JS is the sample which gives back the item count. Since all the rows are read, the scan is again called, I am using the module to wait for the results before issuing the next loop.

  var async = require ('async'); Var AWS = Required ('AAS-SDK'); AWS.config.update ({accessKeyId: 'AKID', secretAccessKey: 'secret', area: 'us-east-1'}); Var svc = new AWS.DynamoDB (); Var scanComplete = false, ItemConnect = 0, PATTKUKI UNITSTAL = 0; Var scanParams = {summary name: 'usertable', count: 'true'}; // scan does not scan all the rows until called again // It uses ASIC modules in order to complete each call before issuing the next call. Async.until (function {return scanComplete;} function (callback) {svc.scan (scanParams, function (hey, result) {if (mistake) {console.log (mistake);} else {console.log ( results), if (typeof (result.LastEvaluatedKey) === 'undefined') {scanComplete = true} else {// set start key for the next scan our last key scanParams.ExclusiveStartKey = result.LastEvaluatedKey;} itemCountTotal + = result.Count; consumedCapacityUnitsTotal + = result.ConsumedCapacityUnits, if (! scanComplete) {console.log ( "cumulative ITEMCOUNT" + itemCountTotal); console.log ( "cumulative capacity units" + consumedCapacityUnitsTotal);}} callback (fault );});}, // It runs when the loop is complete Gets or gives an error function (error) {if (err) {console.log ( 'processing error') scans; console.log (err);} else {Console.log ( 'Full Scan') console.log ( 'Total items: "+ Aitmkounttetl); console.log (' has plenty of capacity units: '+ consumedCapacityUnitsTotal);}});    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -