See Quick Start Node-oracledb Installation.
$ npm i egg-oracle --save
- enable plugin
// {app_root}/config/plugin.js
exports.oracle = {
enable: true,
package: 'egg-oracle',
};
- oracle connection pool attach in app
// {app_root}/app/service/my_service.js
'use strict';
const Service = require('egg').Service;
class MyService extends Service {
// example for getConnection
async foo() {
const connection = await this.app.oracle.getConnection();
const result = await connnection.execute('SELECT sysdate AS "date" FROM dual');
connection.close();
console.log(result.rows[0].date);
}
}
module.exports = MyService;
See Documentation for the Oracle Database Node.js Add-on.
// {app_root}/config/config.default.js
exports.oracle = {
client: {
user: 'user',
password: 'password',
connectString: 'localhost/orcl',
},
};
see config/config.default.js for more detail.