Skip to content

Commit db982c2

Browse files
committed
docs: new style service file
1 parent d3a3991 commit db982c2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ exports.oracle = {
4848
```js
4949
// {app_root}/app/service/my_service.js
5050
'use strict';
51-
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(result.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(result.rows[0].date);
66-
}
51+
const Service = require('egg').Service;
52+
53+
class MyService extends Service {
54+
// example for getConnection
55+
async foo() {
56+
const connection = await this.app.oracle.getConnection();
57+
const result = await connnection.execute('SELECT sysdate AS "date" FROM dual');
58+
connection.close();
59+
console.log(result.rows[0].date);
60+
}
61+
// it work
62+
async foo2() {
63+
const result = await this.app.oracle.execute('SELECT sysdate AS "date" FROM dual');
64+
connection.close();
65+
console.log(result.rows[0].date);
6766
}
68-
return MyService;
6967
}
68+
module.exports = MyService;
69+
7070
```
7171
## Configuration
7272

0 commit comments

Comments
 (0)