Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda