update Pool model

This commit is contained in:
Michael Fatemi 2021-04-11 14:45:32 -04:00
parent f3ae54ffc4
commit 4947d68bb1
2 changed files with 6 additions and 1 deletions

View File

@ -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(),
},
},
}

View File

@ -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);