I need to return the value in EJS Template.. So I need to return the results outside mongoose which i got from mongoose lookup .I have tried to declare the response variable globally but its not working . If I used inside the mongoose its working fine And I am getting the results in Array [false,true,true]
app.locals.myrole_check = function(role_master,page_name,callback){
    var id =  ObjectId(role_master.id);
    var response = [];
      mongo.user.aggregate([
            { $lookup:
                {
                from: 'roles',
                localField: 'role_type',
                foreignField: 'role_name',
                as: 'rolesforusers'
                }
            },
    { $unwind: "$rolesforusers" },
    { $match: { '_id':  id}},
    {"$project": {
      "name": "$rolesforusers.role_name",
      "role": "$rolesforusers.role"
    }}
    ]) .exec(function(err, result){
        var response = [];
        add_role =[];
        edit_role =[];
        delete_role =[];
 if(result[0]){
        if(result[0].role.length!=0)
            {
            if(result[0]['role'].add)
            {
            add_role =  result[0]['role'].add.indexOf(page_name) > -1;
            }
            else {
            add_role = false;
            }
            if(result[0]['role'].edit)
            {
            edit_role =  result[0]['role'].edit.indexOf(page_name) > -1;
            }
            else {
            edit_role = false
            }
            if(result[0]['role'].del)
            {
            delete_role =  result[0]['role'].del.indexOf(page_name) > -1;
            }
            else {
            delete_role =false
            }
        }
     else if(result[0].role.length==0) {
            add_role = true;
            edit_role = true;
            delete_role = true;
        }
 response.push(add_role);
 response.push(edit_role);
 response.push(delete_role);
 console.log(response);
 callback(response);
 }
    });
console.log(response); // I need to get the value here and have to return because i have to use the values in ejs template
}
app.locals.myrole_check1 = function(role_master,page_name,callback){
console.log(response); // Not getting the result here }
Give me some suggestion to get resolve this issue
