These are chat archives for Automattic/mongoose

16th
Oct 2018
Hitesh Joshi
@evoxtorm
Oct 16 2018 04:56
let tM = data.companyWorked.find(function(value) {
                    if (value.companyId._id == req.companyId) {
                        Trainer.findOne({
                            userId: userId
                        }, {
                            userId : 1,
                            companyId : 1,
                        }).exec(function (err, trainerData){
                            if (err) {
                                console.log(err);
                            } else if (!trainerData) {
                                console.log("No trainer data");
                                return false;
                            } else {
                                console.log("Trainer data");
                                isNew2 = false;
                                return true;
                            }
                        })
                    }
                })
hey this find function is giving undefined
anyone knows
Kev
@lineus
Oct 16 2018 09:38
@evoxtorm you need to handle the error in the callback to find as the first parameter to the find callback.
Hitesh Joshi
@evoxtorm
Oct 16 2018 10:36
ok sure thanks