Comparing Mongoose Object Ids
Forget about nonsense like this in order to compare two Mongoose Ids
if (val.user.toString() === submissionDoc.owner._id.toString()){
//do stuff
}
Use a built in Mongoose function instead!
if (val.user.equals(submissionDoc.owner._id)){
//do stuff
}
Or don’t, be convoluted, but before you decide on that check the Zen of Python and see if you can be swayed ;)