Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "blogStatus": "published",
- "blogContent": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.,
- "storeId": "10",
- "tagDate": "Thu Mar 07 2019 18:02:33 GMT+0530 (India Standard Time)",
- "type": "comment",
- "blogTitle": "best hospitalsss",
- "createdDate": "Thu Mar 07 2019 18:02:33 GMT+0530 (India Standard Time)",
- "Comments": [
- {
- "date": "Fri Mar 08 2019 10:24:50 GMT+0530 (India Standard Time)",
- "userEmail": "liza@gmail.com",
- "id": "4e4e8210-415e-11e9-bd72-a17467608922",
- "userName": "liza",
- "status": "draft",
- "replies": [
- {
- "date": "Fri Mar 08 2019 09:54:00 GMT+0530 (India Standard Time)",
- "userEmail": "liza1@gmail.com",
- "id": "ff3096e0-4159-11e9-9315-652881dffd8b",
- "userName": "liza1",
- "status": "draft"
- },
- {
- "date": "Fri Mar 08 2019 09:54:00 GMT+0530 (India Standard Time)",
- "userEmail": "liza2@gmail.com",
- "id": "ff3096e0-4159-11e9-9315-652881dffd8b",
- "userName": "liza2",
- "status": "draft"
- }
- }
- ]
- ]
- app.post('/api/v1/reply/:id', function (req, res) {
- var blogId = req.params.id;
- var replyId = uuid.v1();
- var d = new Date();
- var date = d.toString();
- const {
- reply,
- userName,
- userEmail,
- status
- } = req.body
- var params = {
- TableName: "BlogTest",
- Key: {
- "id": blogId,
- },
- UpdateExpression: "SET #comments[0].#replies = :attrValue",
- ExpressionAttributeNames: {
- '#comments': 'Comments',
- '#replies': 'replies'
- },
- "ExpressionAttributeValues": {
- ":attrValue": [{ id: replyId, date: date, message:reply, userName:userName, userEmail:userEmail,status:status},{ id: replyId, date: date, message:reply, userName:userName, userEmail:userEmail,status:status}]
- },
- ReturnValues: "UPDATED_NEW"
- };
- console.log(params);
- docClient.update(params, (error) => {
- if (error) {
- console.log(error);
- res.status(400).json({ error: 'Could not create reply' });
- }
- res.status(200).json({ success: 'Created the reply' });
- // res.json({ id, name, info });
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement