Skip to content

Commit da3a1bb

Browse files
committed
docs(README):add an example
1 parent c73f754 commit da3a1bb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,40 @@ $ npm i egg-oracle --save
3434

3535
## Usage
3636

37+
* open plugin
38+
3739
```js
3840
// {app_root}/config/plugin.js
3941
exports.oracle = {
4042
enable: true,
4143
package: 'egg-oracle',
4244
};
4345
```
46+
* oracle attach in app
47+
48+
```js
49+
// {app_root}/app/service/my_service.js
50+
'use strict';
4451

52+
module.exports = app => {
53+
class MyService extends app.Service {
54+
// example for getConnection
55+
async foo() {
56+
const connection = await app.oracle.getConnection();
57+
const result = await connnection.execute('SELECT sysdate AS "date" FROM dual');
58+
connection.close();
59+
console.log(sesult.rows[0].date);
60+
}
61+
// it work
62+
async foo2() {
63+
const result = await app.oracle.execute('SELECT sysdate AS "date" FROM dual');
64+
connection.close();
65+
console.log(sesult.rows[0].date);
66+
}
67+
}
68+
return MyService;
69+
}
70+
```
4571
## Configuration
4672

4773
```js

0 commit comments

Comments
 (0)