amazon web services - DynamoDB UpdateItem Doesn't Work -
this pretty straight out of documentation (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/expressions.modifying.html), things aws, doesn't work , isn't documented @ all.
the following fails "the document path provided in update expression invalid update"
var messageid = "f244ed33-d678-4763-8f46-0f06514d5139" var sequenceid = "00000000-0000-0000-0000-000000000000" var = datetime.utcnow; var lastactivitythreshold = now.subtract(timespan.fromseconds(10)); var response = client.updateitem(new updateitemrequest { tablename = "thetable", key = new dictionary<string, attributevalue> { { "sequenceid", new attributevalue { s = sequenceid } } }, expressionattributevalues = new dictionary<string, attributevalue> { {":messageid", new attributevalue {s = messageid}}, {":now", new attributevalue {n = now.ticks.tostring()}}, {":lastactivitythreshold", new attributevalue {n = lastactivitythreshold.ticks.tostring() }}, }, updateexpression = "remove messages[0] set lastactivity = :now", conditionexpression = "messages[0] <> :messageid , (lastactivity <= :lastactivitythreshold or attribute_not_exists(lastactivity))", returnvalues = returnvalue.updated_new });
this document i'm trying update (as seen in json view in aws management console):
{ "lastactivity": { "n": "635753575712635873" }, "messages": { "ss": [ "f244ed33-d678-4763-8f46-0f06514d5139", "f668d2a5-3a4a-4564-8384-5b5a51c9bad3" ] }, "sequenceid": { "s": "00000000-0000-0000-0000-000000000000" } }
i've tried many variations of code above, striaght down removing expressionattributevalues
, conditionexpression
, using remove messages[0]
, doesn't work , throws same error.
it looks you're trying apply document path non json item. there's no concept of ordering in set, if want remove first item, you'll need load memory , iterate on it. in short, you'll need use list in case.
Comments
Post a Comment