Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get items in dynamodb nodejs

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'});

var params = {
  TableName: 'TABLE',
  Key: {
    'KEY_NAME': {N: '001'}
  },
  ProjectionExpression: 'ATTRIBUTE_NAME'
};

// Call DynamoDB to read the item from the table
ddb.getItem(params, function(err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Item);
  }
});
Comment

dynamodb get all items nodejs

var docClient = new AWS.DynamoDB.DocumentClient();

var params = {
    TableName: "users",
    FilterExpression: "#user_status = :user_status_val",
    ExpressionAttributeNames: {
        "#user_status": "user_status",
    },
    ExpressionAttributeValues: { ":user_status_val": 'somestatus' }

};

docClient.scan(params, onScan);
var count = 0;

function onScan(err, data) {
    if (err) {
        console.error("Unable to scan the table. Error JSON:", JSON.stringify(err, null, 2));
    } else {        
        console.log("Scan succeeded.");
        data.Items.forEach(function(itemdata) {
           console.log("Item :", ++count,JSON.stringify(itemdata));
        });

        // continue scanning if we have more items
        if (typeof data.LastEvaluatedKey != "undefined") {
            console.log("Scanning for more...");
            params.ExclusiveStartKey = data.LastEvaluatedKey;
            docClient.scan(params, onScan);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop through object in array javascript 
Javascript :: mongoose connect to mongodb 
Javascript :: angular add a new line from component 
Javascript :: js onchange input value event listene 
Javascript :: using map in useeffect 
Javascript :: how to find length of array in javascript without using length method 
Javascript :: jquery find selected option by class 
Javascript :: string contains string javascript 
Javascript :: javascript sort array of objects by key value 
Javascript :: jest writing test 
Javascript :: regex link validation 
Javascript :: number of repetition in an array javascript 
Javascript :: moment format date 
Javascript :: local storage remove multiple items 
Javascript :: pwa angular npm 
Javascript :: javascript random numbers 
Javascript :: js capitalize 
Javascript :: get hover element js 
Javascript :: Angular version chrome console 
Javascript :: javascript get parent element height javascript 
Javascript :: example of pre increment in js 
Javascript :: javascript generate random numbers 
Javascript :: can you call api in next.js getserverside props 
Javascript :: join array of object name javascript 
Javascript :: delay input javascript 
Javascript :: concantene number in js 
Javascript :: javascript detect if object is date 
Javascript :: nodejs csv to json from link 
Javascript :: window.print a div 
Javascript :: moment().toDate(); 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =