| function buildFactResponse(myName, myQuestion) { | |
| return new Promise((resolve, reject) => { | |
| if (myQuestion !== undefined) { | |
| let params = {}; | |
| params.TableName = "AzureFacts"; | |
| params.Key = {"Fact": myQuestion}; | |
| params.UpdateExpression = "set Hits = Hits + :val"; | |
| params.ExpressionAttributeValues = {":val": 1}; | |
| params.ReturnValues = "ALL_NEW"; | |
| docClient.update(params, function (err, data) { | |
| if (err) { | |
| console.log("GetItem threw an error:", JSON.stringify(err, null, 2)); | |
| reject(err); | |
| } else { | |
| console.log("GetItem succeeded:", JSON.stringify(data, null, 2)); | |
| resolve(data); | |
| } | |
| }); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment