我有一个非常嵌套的商品DynamoDB数据模型,并且我想根据条件更新商品JSON中的特定值,但我想不出一个很好的方法来做到这一点。我的数据模型的简化版本如下:
{
"name": "test",
"Script": [
{
"DeliverDate": "26-09-2018",
"ID": "SCR001",
"Name": "SCR001",
"nonname": "automation",
"Purpose": "Help",
"Status": "null",
"Time": "4"
},
{
"DeliverDate": "27-09-2018",
"ID": "SCR002",
"Name": "2",
"nonname": "automation",
"Purpose": "Help2",
"Status": "Validated",
"Time": "5"
}
],
"Header": [
{
"ID": "DEV001",
"Name": "API",
"nonname": "project",
"Status": "null",
"Time": "10"
}
],
"Forms": [
{
"ID": "SHIFT001",
"nonname": "Forms",
"reply word count": "300",
"Shiftdate": "21-09-2018",
"Status": "null",
"Time": "8",
"URL": "https://www.google.com"
}
],
"Testing": [
{
"Gone": "tests123",
"EndDate": "15-06-2018",
"ID": "HIRING001",
"location": "London",
"nonname": "testing",
"StartDate": "15-06-2018",
"Status": "null",
"Time": "22"
}
],
"ABC": [
{
"ID": "ABC001",
"nonname": "query",
"Percentage": "100%",
"PublishedDate": "26-12-2018",
"Status": "null",
"Time": "400",
"Title": "trail",
"URL": "http://google.com"
}
],
"BCD": [
{
"Duration": "2",
"ID": "BCD001",
"nonname": "BCD",
"PublishedDate": "26-12-2018",
"Status": "null",
"Time": "400",
"Title": "AWS App"
}
],
"HELLO": [
{
"Article name": "User",
"Article url": "http://google.com",
"ID": "HELLO001",
"nonname": "HELLO",
"Publish Date": "24-10-2018",
"Status": "null",
"Time": "800",
"Views": "300",
"Word Count": "500"
}
],
"MASSEFFECT": [
{
"DilieverDate": "26-12-2018",
"ID": "MASSEFFECT001",
"nonname": "l3",
"SessionDuration": "4",
"Status": "null",
"Time": "400",
"topic": "API"
}
],
"DEADSPACE": [
{
"ID": "DEADSPACE001",
"Month": "Jan",
"nonname": "DEADSPACE",
"Status": "null",
"Time": "300",
"Year": "2018"
}
],
"GAMING": [
{
"Batch": "Batch",
"DelieverDate": "26-12-2018",
"ID": "GAMING001",
"nonname": "GAMING",
"Profile": "trial",
"SessionDuration": "4",
"Status": "null",
"Time": "400",
"Topic": "GAMING"
}
],
"ZOO": [
{
"ActivityName": "ZOO",
"EndTime": "Everything happens",
"ID": "ZOO001",
"nonname": "others",
"ProofSubmitted": "Everything happens all once.",
"StartTime": "avc",
"Status": "null",
"Time": "keyword"
},
{
"ActivityName": "PS4",
"EndTime": "Everything happens!!!!!",
"ID": "OTHER001",
"nonname": "others",
"ProofSubmitted": "Everything happens all once.",
"StartTime": "avc",
"Status": "null",
"Time": "keyword"
}
],
"WORK": [
{
"Date": "26-12-2018",
"ID": "WORK001",
"nonname": "work",
"Status": "null",
"Time": "4",
"Topic": "work"
}
]
}
在此用例中,如果该块中的“ ID”字段包含特定值,我想更新该块中的“ Status”参数。 例如,如果块中的“ ID”为“ WORK001”,我想将状态更改为“已更改”,并且我的用例涉及根据ID更改任何JSON子块的“状态”字段在那个子块中。
示例:
"WORK": [
{
"Date": "26-12-2018",
"ID": "WORK001",
"nonname": "workshop",
"Status": "null",
"Time": "4",
"Topic": "workshop"
}
]
收件人:
"WORK": [
{
"Date": "26-12-2018",
"ID": "WORK001",
"nonname": "work",
"Status": "Changed",
"Time": "4",
"Topic": "work"
}
]
我已经研究了AWS文档中的UpdateItem API调用和PutItem API调用,但是我找不到在此用例中利用API调用的好方法。关于如何执行此操作的任何帮助将非常有帮助。提前致谢。