I am using appsync to store my data to dynamoDB and have 2 tables in dynamoDB. 1 table named Projects storing
ID, data, userID
and another table named UserProjects intending to store userID with all the IDs of the projects that the user owns, this is required as i am looking to implement sharing of projects (just adding the ID of the project to the userID)
However, I am having trouble writing the resolver for appsync- dynamoDB. as I want to add AWSJSON objects to the empty map in dynamoDB
Example at start:
Starting DB, an empty map through this resolver code called
{
"version" : "2017-02-28",
"operation" : "UpdateItem",
"key" : {
"UserEmail" : { "S" : "${context.arguments.UserEmail}" }
},
"update": {
"expression": "SET #Projects = :emptyMap",
"expressionNames": {
"#Projects" : "Projects"
},
"expressionValues": {
":emptyMap" : {"M" : {}}
}
},
"condition": {
"expression" : "attribute_not_exists(UserEmail)"
}
}
This is the end result I want, to be able to add one AWSJSON set into "Projects"
I have tried to find stackoverflow but all of the examples are in Java/javascript
and I have tried this but to no avail
{
"version" : "2017-02-28",
"operation" : "UpdateItem",
"key" : {
"UserEmail" : { "S" : "${context.arguments.UserEmail}" }
},
"update" : {
"expression" : "SET #Projects.#Key = :test",
"expressionName": {
"#Projects": "Projects"
"#Key": "key"
},
"expressionValues": {
":test" : $util.toJson(${context.arguments.Projects})
}
}
}