我有一个使用node-oracledb连接到Oracle的Node/Express.js应用程序。
我试图将多个查询返回给我的视图,但是我在Node-Oracle项目中找到的所有示例都是针对单个查询的。https://github.com/oracle/node-oracledb/tree/master/examples
网上有各种各样的信息,但我找不到与这种情况有关的任何东西,没有一个我可以使用的例子。我找到的最接近的问题是:oracledb chaining sql call using promises,它被带到Github,但没有真正得到答案。
到目前为止,我的工作代码是:
var express = require('express');
var router = express.Router();
var oracledb = require('oracledb');
/* GET home page. */
router.get('/', function(req, res, next) {
oracledb.getConnection()
.then(function(connection) {
return connection.execute(
"SELECT note_id, name " +
"FROM notes " +
"WHERE note_id = :did",
[1234]
)
.then(function(result) {
res.render('index', { title: 'Express', table: result });
return connection.close();
}).catch(function(err) {
console.log(err.message);
return connection.close();
})
})
.catch(function(err) { console.log(err.message); })
});
module.exports = router;如何才能处理多个查询并将结果传递给模板?
res.render('index', { title: 'Express', table: result, table2: result2 });编辑:我的示例基于此:https://github.com/oracle/node-oracledb/blob/master/examples/promises.js
https://stackoverflow.com/questions/41350347
复制相似问题