Mongoose plugin to normalize stored dates timezone.
BSD 3-Clause "New" or "Revised" License
15
stars
6
forks
source link
Got - " Cannot read property 'constructor' of null " on using 'model.findOne' query #7
Closed
integratechnologies closed 5 years ago
Got - " Cannot read property 'constructor' of null " on using 'model.findOne' query since docs is null if findOne query results in no results.
Check to verify if (docs!=null) will solve this issue.
function subtractOffset(docs, next) { const documents = []; if(docs!=null){ if (!Array.isArray(docs)) { documents.push((docs.constructor.name === 'model') ? docs : this); } else { documents.push(...docs); } } documents.forEach(result => fixOffset(result, false)); next(); }