使用egg-oracle插件配置

安装

npm i egg-oracle --save

// {app_root}/config/plugin.js 启用插件

module.exports = {
oracle :{
enable: true,
package: ‘egg-oracle’,
}
};

// {app_root}/config/config.default.js 增加配置

config.oracle = {
client: {
user: ‘cps2’,
password: ‘cps2’,
connectString: ‘localhost/gym’,
},
};

// {app_root}/app/service/my_service.js 例子

// {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 connection.execute(‘SELECT sysdate AS “date” FROM dual’);
connection.close();
console.log(result.rows[0].date);
}
}
module.exports = MyService;

发布了2 篇原创文章 · 获赞 0 · 访问量 89

猜你喜欢

转载自blog.csdn.net/jxqd068423/article/details/104042959
egg
今日推荐