title: dynamodb updateitem with conditionexpression return whether item updated
body: <p>I would like to update an item under certain conditions and then I would like to know whether the item was updated when UpdateItem returns.</p>
  
  <p>The documentation seems contradictory to me. </p>
  
  <p>On this page: <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html" rel="nofollow">http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html</a> in the "Conditional Update" example it says "All of the item's attributes, as they appear after the update, are returned in the response."</p>
  
  <p>On this page: <a href="https://godoc.org/github.com/aws/aws-sdk-go/service/dynamodb#UpdateItemOutput" rel="nofollow">https://godoc.org/github.com/aws/aws-sdk-go/service/dynamodb#UpdateItemOutput</a> it says that Attributes is "A map of attribute values as they appeared before the UpdateItem operation"</p>
  
  <p>I don't really want either of these. What I want is a bool that says whether or not there was an update.</p>
  
  <p>This is where my brain is at now:</p>
  
  <pre><code>out, err := db.DynamoDB.UpdateItem(&amp;dynamodb.UpdateItemInput{
      TableName: tableName,
      Key: map[string]*dynamodb.AttributeValue{
          "KeyName": {S: aws.String(keyname)},
      },
      ExpressionAttributeNames: map[string]*string{
          "#lock": aws.String("Lock"),
      },
      ExpressionAttributeValues: map[string]*string{
          ":now":     aws.String(compfmt(time.Now())),
          ":promise": aws.String(compfmt(time.Now().Add(30 * time.Second))),
      },
      ConditionExpression: aws.String("attribute_not_exist(#lock) OR :now &gt; #lock"),
      UpdateExpression:    aws.String("SET #lock = :promise"),
  })
  </code></pre>