title: Problems to query last entry in DynamoDB - Always endup with NULL
body: <p>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.</p>
  <p>Please help me move forward. Any suggestion, tip,… is more than welcome. Really appreciate that.</p>
  <p>Here is the code of my lambda :</p>
  <pre><code>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(&quot;DDB ERROR MG: &quot;, err)
    }
  }
  
  module.exports = getLastAliine3
  </code></pre>