我想使用Expres.js和knex.js两个表进行渲染,只使用一个get函数,以便在一个HTML模板中使用两个表中的数据.当我只查询一个表(学校或学生)但我不知道如何处理两个表时,它可以工作.有什么建议吗?
app.get('/schools', function(req, res) {
knex.select()
.from('schools', 'students')
.then(function(schools, students) {
res.render('schools', {
schools: schools,
students: students
});
}).catch(function(error) {
console.log(error);
});
});
Run Code Online (Sandbox Code Playgroud)