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

374
Views
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
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!