Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active August 14, 2018 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garystafford/7e08d8997b07364d18c4891c2e5bc8e5 to your computer and use it in GitHub Desktop.
Save garystafford/7e08d8997b07364d18c4891c2e5bc8e5 to your computer and use it in GitHub Desktop.
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