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

375
Vistas
Lambda function to delete item in DynamoDB not working properly

I have the following Lambda function to delete an item from my DynamoDB.

const AWS = require("aws-sdk");
AWS.config.update({ region: "us-west-2" });

var docClient = new AWS.DynamoDB.DocumentClient();

var deleteContact = function(event,callback) {
    
    var params = {
        TableName:"Contacts",
        Key:{
            id: event.id
        },
        ConditionExpression: "set event.id = :id",
        ExpressionAttributeValues: {
            ":id": event.id
        }
    };
    
    console.log("Attempting a conditional delete...");
    docClient.delete(params, function(err, data) {
        if (err) {
            console.error("Unable to delete item. Error JSON:", JSON.stringify(err, null, 2));
        } else {
            console.log("DeleteItem succeeded:", JSON.stringify(data, null, 2));
        }
    });
};

deleteContact();

and here is the code in my react app which is requesting:

export const removeContact = createAsyncThunk(
  'contactsApp/contacts/removeContact',
  async (contactId, { dispatch, getState }) => {
    await axios.post('https://API.amazonaws.com/prod', { 
      key1: `${contactId}`
     });
    console.log(contactId)
    return contactId;
  }
);

Currently, code works and deletes the parameters in the row. But the problem is it will not remove the id from the DynamoDB table. So everything will be deleted EXCEPT id.
As result, I would have GHOST items in my DynamoDB table: DynamoDB screenshot

about 4 years ago · Juan Pablo Isaza
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