PutItem

Description

The PutItem function creates an item, or replaces an old item with a new item.

For more information, see PutItem.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.putItem(requestParameters)

Parameters

See request parameters of PutItem.

Example

<cfscript> 
 cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = getCloudService(cred, config) 
  movieName="Movies008" 
 
  // Stage 1: create a table 
  tableStruct={ 
    TableName : "#movieName#", 
    KeySchema:[ 
        { AttributeName: "year", KeyType: "HASH"},  //Partition key 
        { AttributeName: "title", KeyType: "RANGE"}  //Sort key 
    ], 
    AttributeDefinitions:[ 
        { AttributeName: "year", AttributeType: "N" }, 
        { AttributeName: "title", AttributeType: "S" } 
    ], 
    ProvisionedThroughput:{ 
        ReadCapacityUnits: 10, 
        WriteCapacityUnits: 10 
    } 
 } 
 dynamo.createTable(tableStruct) 
 sleep(3000) 
 
 // Stage 2: insert an item into the table 
 
 putItemStruct={ 
    "TableName":"#movieName#", 
    "Item":{ 
      "year": {"N": 2019}, 
      "title": {"S": "Golden"} 
    }, 
    "ReturnValues": "NONE" 
 } 
 
 try{ 
    putItemResponse=dynamo.putItem(putItemStruct,{"hasType": true}) 
    writeOutput("Item inserted successfully in the table.") 
    writeDump(putItemResponse) 
 } 
 catch (any e){ 
    writeDump(e) 
 } 
</cfscript>

Output

PutItem output
PutItem output

Get help faster and easier

New user?