File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
test/fixtures/multi/src/subsystem Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11import {
22 APPLICATION_KEY ,
3+ ApplicationContext ,
34 Configuration ,
45 IMidwayContainer ,
56 Init ,
67 Inject ,
78 MidwayDecoratorService ,
89 REQUEST_OBJ_CTX_KEY ,
10+ ScopeEnum ,
911} from '@midwayjs/core' ;
1012import { LeoricDataSourceManager } from './dataSourceManager' ;
1113import { DATA_SOURCE_KEY , MODEL_KEY } from './decorator' ;
@@ -30,6 +32,9 @@ export class LeoricConfiguration {
3032 @Inject ( )
3133 decoratorService : MidwayDecoratorService ;
3234
35+ @ApplicationContext ( )
36+ applicationContext : IMidwayContainer ;
37+
3338 dataSourceManager : LeoricDataSourceManager ;
3439
3540 @Init ( )
@@ -47,9 +52,9 @@ export class LeoricConfiguration {
4752 this . dataSourceManager . getDefaultDataSourceName ( )
4853 ) ;
4954 const model = dataSource . models [ getModelName ( meta . modelName ) ] ;
50- const ctx = instance [ REQUEST_OBJ_CTX_KEY ] ;
5155 const app = instance [ APPLICATION_KEY ] ;
52- if ( ctx ) {
56+ if ( this . applicationContext . getInstanceScope ( instance ) === ScopeEnum . Request ) {
57+ const ctx = instance [ REQUEST_OBJ_CTX_KEY ] ;
5358 return class extends model {
5459 static get ctx ( ) {
5560 return ctx ;
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ export class PostController {
88
99 @Get ( '' )
1010 async get ( ) {
11- return await this . postService . get ( ) ;
11+ const data = await this . postService . get ( ) ;
12+ console . log ( data ) ;
13+ return data ;
1214 }
1315}
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ export default class Post extends Bone {
1010 @Column ( DataTypes . TEXT )
1111 content : string ;
1212
13- @Column ( )
13+ @Column ( { name : 'created_at' } )
1414 createdAt : Date ;
1515
16- @Column ( )
16+ @Column ( { name : 'updated_at' } )
1717 updatedAt : Date ;
1818}
You can’t perform that action at this time.
0 commit comments