-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interlink comment with user #59
base: master
Are you sure you want to change the base?
Conversation
@@ -38,6 +47,12 @@ export async function addComment(req: Request,res:Response){ | |||
} | |||
|
|||
export async function deleteCommentById(req:Request,res:Response){ | |||
|
|||
const user = await userModel.findById(req.params.userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to check if the actual user who created the comment should delete the comment,
check user._id equlaity
@@ -47,11 +62,15 @@ export async function deleteCommentById(req:Request,res:Response){ | |||
} | |||
|
|||
export async function updateCommentById(req:Request,res:Response){ | |||
const user = await userModel.findById(req.params.userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same goes here, one should update their comments.
res.status(200).json(comment); | ||
|
||
// console.log(comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove debugging statements, plus pull the master branch to resolve conflicts.
// console.log(comment) | ||
// const ans = await comment.populate('author'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove debugging statments
.populate([ | ||
{ | ||
path: 'author ', | ||
select: 'name -_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to populate picture of a user also
@@ -2,16 +2,22 @@ import mongoose from 'mongoose'; | |||
import {userModel} from './user-model'; | |||
import {Article} from './article'; | |||
|
|||
export interface comment_interface extends Document{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to rename interfaces with IComment
No description provided.