From 4947d68bb16d8936297f06008aebc0fa2d05e170 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sun, 11 Apr 2021 14:45:32 -0400 Subject: [PATCH] update Pool model --- src/api/pool.ts | 3 +++ src/models.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api/pool.ts b/src/api/pool.ts index f94b3d1..0123b61 100644 --- a/src/api/pool.ts +++ b/src/api/pool.ts @@ -10,6 +10,8 @@ router.post('/:poolID/comment', requireApiAuth, async (req, res) => { const poolID = req.params.poolID; const commentBody = req.body.body; + console.log(req.body); + await PoolModel.updateOne( { _id: poolID }, { @@ -17,6 +19,7 @@ router.post('/:poolID/comment', requireApiAuth, async (req, res) => { comments: { author_id: userID, body: commentBody, + created_at: new Date().toISOString(), }, }, } diff --git a/src/models.ts b/src/models.ts index b12801c..4ab87dc 100644 --- a/src/models.ts +++ b/src/models.ts @@ -15,6 +15,7 @@ export interface Group extends Document { export interface Comment { body: string; author_id: string; + created_at: string; } const UserSchema: Schema = new Schema({ @@ -39,8 +40,9 @@ const GroupSchema: Schema = new Schema({ const GroupModel: Model = model('Group', GroupSchema); const CommentSchema: Schema = new Schema({ - text: { type: String, required: true }, + body: { type: String, required: true }, author_id: { type: String, required: true }, + created_at: { type: String, required: true }, }); const CommentModel = model('Comment', CommentSchema);