我有两个职能。我在两个功能中都执行相同的过程。 function1根据需要更新请求,并且我可以在其他函数中使用数组。 在function2中,数组正在添加到req中,但是当我尝试在其他函数中使用数组时,它正在崩溃。我该如何在function2中做到这一点。谢谢。
功能1:
router.post('/sign_in-sign_in', function(req, res, next) {
var v_sql_application_set=[{$match:{user_id:req.session.user__info.user_id }},{$project:{dim_id:1,application_set:1}}];
querySelect( v_sql_application_set,"t_application_set","aggregate").then(function (application_set_result){
req.session.Qxresult__t_application_set = [];
for (var i = 0; i < application_set_result.length; i++) {
req.session.Qxresult__t_application_set.push({application_set:application_set_result[i].application_set});
}
}).catch(error=>{
console.log("Error in f_refresh_session_vectors :ErrorNo1 "+JSON.stringify(error));
v_cmessage="Unexpected Error. Try Again. (Error in f_refresh_session_vectors :ErrorNo1) "+JSON.stringify(error);
res.render('error',{user_info:req.session.user__info});
});
});
功能2:
function fx_refresh_session_vectors(req)
{
var v_sql_application_set=[{$match:{user_id:req.session.user__info.user_id }},{$project:{dim_id:1,application_set:1}}];
querySelect( v_sql_application_set,"t_application_set","aggregate").then(function (application_set_result){
req.session.Qxresult__t_application_set = [];
for (var i = 0; i < application_set_result.length; i++) {
req.session.Qxresult__t_application_set.push({application_set:application_set_result[i].application_set});
}
}).catch(error=>{
console.log("Error in f_refresh_session_vectors :ErrorNo1 "+JSON.stringify(error));
v_cmessage="Unexpected Error. Try Again. (Error in f_refresh_session_vectors :ErrorNo1) "+JSON.stringify(error);
res.render('error',{user_info:req.session.user__info});
});
}