Horje
find all data in dynamodb lambda Code Example
find all data in dynamodb lambda
//NODE JS
const AWS = require('aws-sdk')
const dynamoDB = new AWS.DynamoDB({ region: 'ap-south-1', apiVersion: '2019.11. 21' })
var docClient = new AWS.DynamoDB.DocumentClient()

exports.handler = async (event, context, cb) => {
  //Getting all data
     let params = {
         TableName: 'TABLE_NAME'
     }
     let results = await docClient.scan(params).promise()
      const response = {
          "statusCode": 200,
          "success": true,
          "message": results.Items,
          "headers": {
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Credentials": true
          }
      };
      return cb(null, response)
  
  //Query in dynamoDB
  let params = {
    TableName: 'TABLE_NAME',
    FilterExpression: "#someKEY = :someKEY_val", // can use 'AND' 'OR' here
    ExpressionAttributeNames: {
      "#someKEY": "userId", // its value should be key you want to lookup
    },
    ExpressionAttributeValues: { ":someKEY_val": "1" } // Value to match
  }
  let results = await docClient.scan(params).promise()
  const response = {
    "statusCode": 200,
    "success": true,
    "message": results.Items,
    "headers": {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Credentials": true
    }
  };
  return cb(null, response)
}




Javascript

Related
get current tab url in chrome extension in popup Code Example get current tab url in chrome extension in popup Code Example
receiving big response node js Code Example receiving big response node js Code Example
add cloudinary to gatsby javascript Code Example add cloudinary to gatsby javascript Code Example
jqueryui droppable enable Code Example jqueryui droppable enable Code Example
limpar html string js Code Example limpar html string js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8