3.0.1 • Published 5 years ago

egg-oracledb v3.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

egg-oracle

NPM version David deps Known Vulnerabilities npm download

Install

See Quick Start Node-oracledb Installation.

$ npm i egg-oracle --save

Usage

  • 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);
  }
  // deprecated!!
  async foo2() {
    const result = await this.app.oracle.execute('SELECT sysdate AS "date" FROM dual');
    connection.close();
    console.log(result.rows[0].date);
  }
}
module.exports = MyService;

Documentation

See Documentation for the Oracle Database Node.js Add-on.

Configuration

// {app_root}/config/config.default.js
exports.oracle = {
  client: {
    user: 'user',
    password: 'password',
    connectString: 'localhost/orcl',
  },
};

see config/config.default.js for more detail.

Example

License

MIT