DeleteItem

Description

This function delete an item in a table via the primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it matches the value of an attribute.

For more information, see DeleteItem.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.deleteItem(requestParameters)

Parameters

See request parameters of DeleteItem.

Example

<cfscript> 
  cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = getCloudService(cred, config) 
  tableName="YearlyProductCatalog" 
  // items to delete 
  id=550 
  title="My Books Title" 
  // delete the item in the table 
  deleteItemStruct={ 
    "TableName":"#tableName#", 
    "Key":{ 
      "id":{"N":"#id#"}, 
      "title":{"S":"#title#"} 
    }, 
    "ReturnValues": "ALL_OLD" 
  } 
  try{ 
    deleteItemResponse=dynamo.deleteItem(deleteItemStruct,{"hasType": true}) 
    writeOutput("Item deleted successfully") 
    writeDump(deleteItemResponse) 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript> 

Output

DeleteItem output
DeleteItem output

 Adobe

Get help faster and easier

New user?