Am trying to query a value that's returned from mongoose callback function, but all I get is TypeError: #<Object> is not a function. I know it might not be easy to do that, but with the way am querying the db I need to dive more deep from the returned results, without really having to call up the User model again. I don't know if there's a way to go around that.
User.findOne({_id: req.user.id}, function(err,user){
if(err){
console.log(err);
} else {
if(user.plan == 'hit'){
User.find({plan: 'hit', verified: 'yes'}).lean().exec(function(error,*suc*){
if(suc.length < 1){
console.log(error);
console.log('no user')
} else {
console.log(suc)
**Error throws up right below here**
*suc*.find({admintit: 'admin', adminLimit: 200, admincycle: 0}, function(errok,hungad){
if(errok){
console.log(err)
} else {
if(hungad.length < 1){
console.log('no hung admin');
} else {
console.log(hungad)
}
}
})
}
})
}
}
})
Really trying to query the suc callback result, but all I get is an error, I have tried converting it to an object Object.assign({}, suc) but it still returns same error, that it's not a function.
*suc*.findintentional, or for emphasis (not in your actual code)?