I have a schema like:
Question { id, user, ... }
Answer { id, user, question, ... }
I want to allow both user who posted answer or the parent question to delete an answer. How can I do it?
I want to remove an Answer
if the userId
param is either Answer.user.id
or Answer.question.user.id
.
The current implementation looks like
Answer.destroy({ id: id, user: loggedInUserId })
And it allows only owner of answer to remove his answer. Missing the part where poster of question can delete any answer under his question