Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Problems to query last entry in DynamoDB - Always endup with NULL

I am a beginner in AWS DynamoDb and am stuck now. I am writing a Lambda Function in node.js to query items from DynamoDb. DeviceID is the Partition Key. The idea is to query the last entry. The challenge is that I always have a “null” outcome.

Please help me move forward. Any suggestion, tip,… is more than welcome. Really appreciate that.

Here is the code of my lambda :

const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient()

async function getLastAliine3(deviceID) {
  const params = {
    TableName: 'AliineTable',
    IndexName: 'deviceID-Ux-index',
    key: {
      deviceID: deviceID
    },
    KeyConditionExpression: 'deviceID= :dID',
    ExpressionAttributeValues: {
      ':dID': 'deviceID'
    },
    ScanIndexForward: false,
    Limit: 1
  }


  try {
    const { Item } = await docClient.query(params).promise()
    return Item
  } catch (err) {
    console.log("DDB ERROR MG: ", err)
  }
}

module.exports = getLastAliine3
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

    ExpressionAttributeValues: {
      ':dID': 'deviceID'
    },

You're passing the string 'deviceId' to the Query instead of the value of your variable. This should fix the problem:

    ExpressionAttributeValues: {
      ':dID': deviceID
    },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!