-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.js
30 lines (25 loc) · 971 Bytes
/
update.js
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
import handler from "./libs/handler-lib";
import dynamoDb from "./libs/dynamodb-lib";
export const main = handler(async (event, context) => {
const data = JSON.parse(event.body);
const params = {
TableName: process.env.tableName,
Key: {
userId: event.requestContext.identity.cognitoIdentityId,
postId: event.pathParameters.id,
},
UpdateExpression:
"SET postBlurb = :postBlurb, postLink = :postLink, postLanguage = :postLanguage, postKeywords = :postKeywords, postRating = :postRating, attachment = :attachment",
ExpressionAttributeValues: {
":postBlurb": data.postBlurb || null,
":postLink": data.postLink || null,
":postLanguage": data.postLanguage || null,
":postKeywords": data.postKeywords || null,
":postRating": data.postRating || null,
":attachment": data.attachment || null,
},
ReturnValues: "ALL_NEW",
};
await dynamoDb.update(params);
return { status: true };
});