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 :: how is javascript compiled 
Javascript :: vue 3 script setup dynamic component sample 
Javascript :: mongoose pagination with total count 
Javascript :: vue call method after render 
Javascript :: ajax select2 
Javascript :: perspective camera three js 
Javascript :: js hexadecimal 
Javascript :: how to set the development mode in webpack 
Javascript :: html2pdf example angular 
Javascript :: javascript set input value by id 
Javascript :: If statement discord js 
Javascript :: circular progress for react 
Javascript :: what is normalize in javascript 
Javascript :: discord chatbot 
Javascript :: how to use console.log in vuejs 
Javascript :: how to filter json array in javascript 
Javascript :: node js on macbook m1 
Javascript :: user input in js 
Javascript :: plotly react 
Javascript :: jquery option not disabled 
Javascript :: switch alert 
Javascript :: how to get the inner width of a parent div for canvas 
Javascript :: react native paper modal background 
Javascript :: react promises 
Javascript :: create an element jquery 
Javascript :: nuxt eslint prettier vetur 
Javascript :: Web History API 
Javascript :: img src to file javascript 
Javascript :: match the pattern in the input with javascript 
Javascript :: how to open print dialog box on button click 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =