Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda