-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateWorkoutUsedDate.js
More file actions
31 lines (28 loc) · 896 Bytes
/
updateWorkoutUsedDate.js
File metadata and controls
31 lines (28 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as dynamoDbLib from "./libs/dynamodb-lib";
import { success, failure } from "./libs/response-lib";
//updates the last used date for the workout
export async function main(event, context) {
const data = JSON.parse(event.body);
console.log("HIII");
console.log(JSON.stringify(data));
const params = {
TableName: "swim_workout_table",
Key: {
username: data.username,
workout_id: data.workout_id
},
UpdateExpression: "SET last_used = :last_used_value",
ExpressionAttributeValues: {
":last_used_value": new Date().toLocaleString("en-US", {timeZone: "America/Chicago"}).toString()
},
ReturnValues: "NONE"
};
try {
await dynamoDbLib.call("update", params);
console.log(params.Item);
return success(params.Item);
} catch (e) {
console.log(e.message);
return failure({ status: false, message: e.message });
}
}