i have code blow and need to replace the "doc" (query result) with projectsDocument, but projectsDocument not defined in the function,please help me!!!!
var projectsDocument, categoryDocument; //empty
    projectsModel.find({}, {}, (err, doc) => {
        if (err) return next(err);
        if (doc) {
            projectsDocument = doc; 
        }
    });
    console.log(projectsDocument); //want to projectsDocument be equals to doc
[SOLVED]
i change my code to this and it works
    router.get('/', async(req, res, next) => {
    await projectsModel.find().then(function(doc) {
        projectsDocument = doc;
    }).catch(function(error) {
        console.log(error);
    });
});
 
    