I am new in Nodejs and I am using express JS framework with MVC pattern I want to get data from two different tables (with use of two different functions in model) in single controller function, Can I do this ?
-- Here is my Model
sensorModel.getAllSensorSite=function(result){
sql.query("SELECT * FROM site",function(err,res){
if(err) {
return result(err,null);
}
else{
return result(null,res);
}
});
}
sensorModel.getAllSensorRowss=function(result){
sql.query("SELECT * FROM rowss",function(err,res){
if(err) {
return result(err,null);
}
else{
return result(null,res);
}
});
}
-- Here is my Controller
sensorController.index=function(req,res,next){
sensorModel.getAllSensorSite(function(err,site){
if(err){
throw err;
}else{
res.json({ site });
}
});
}