Error - can't convert undefined to object : DBCollection.prototype.findOneAndUpdate

The way your code is presented is very hard to understand. Please take a look at following and edit your post accordingly. It will help us help you better.