skip to Main Content

MongoDb findOne query results in error – even if data is found

the below is my controller function exports.validateUsername = async (uName) => { console.log("inside validate username"); await User.findOne({ username: "sab2" }).then(function (err, user) { if (err) { console.log("inside err"); console.log("error"); console.log(err); return true; } else { console.log("inside user found"); console.log("user"); console.log(user);…

VIEW QUESTION

How to merge two mongodb query into one

I have two mongodb aggregate query as shown below. The below query gives me the count of total failed and the sectionType db.Departments.aggregate([ { $match: {$and: [{"subject.failed": {$eq: 'true'}}, {"section": {$eq: 'A'}}]} }, { $group: { _id: {"sectionType": "$sectionType"}, "COUNT(*)":…

VIEW QUESTION
Back To Top
Search