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<Group> = 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);