-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(): Remove ORM specific query service decorators
- Loading branch information
1 parent
282c421
commit cd09abe
Showing
15 changed files
with
33 additions
and
68 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/core/__tests__/decorators/inject-query-service.decorator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as nestjsCommon from '@nestjs/common'; | ||
import { QueryService, InjectQueryService, getQueryServiceToken } from '../../src'; | ||
|
||
describe('@InjectQueryService', () => { | ||
const injectSpy = jest.spyOn(nestjsCommon, 'Inject'); | ||
|
||
class TestEntity {} | ||
|
||
it('call inject with the correct key', () => { | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
class Test { | ||
constructor(@InjectQueryService(TestEntity) readonly service: QueryService<TestEntity>) {} | ||
} | ||
expect(injectSpy).toBeCalledTimes(1); | ||
expect(injectSpy).toBeCalledWith(getQueryServiceToken(TestEntity)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Class } from '../common'; | ||
|
||
export function getQueryServiceToken<DTO>(DTOClass: Class<DTO>): string { | ||
return `${DTOClass.name}QueryService`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { getQueryServiceToken } from './helpers'; | ||
export { InjectQueryService } from './inject-query-service.decorator'; |
5 changes: 5 additions & 0 deletions
5
packages/core/src/decorators/inject-query-service.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { Class } from '../common'; | ||
import { getQueryServiceToken } from './helpers'; | ||
|
||
export const InjectQueryService = <DTO>(entity: Class<DTO>): ParameterDecorator => Inject(getQueryServiceToken(entity)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { QueryService, getQueryServiceToken } from './query.service'; | ||
export { QueryService } from './query.service'; | ||
export { AssemblerQueryService } from './assembler-query.service'; | ||
export { RelationQueryService, QueryServiceRelation } from './relation-query.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
...ges/query-sequelize/__tests__/decorators/inject-sequelize-query-service.decorator.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/query-sequelize/src/decorators/inject-sequelize-query-service.decorator.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { SequelizeQueryService } from './services'; | ||
export { InjectSequelizeQueryService } from './decorators'; | ||
export { NestjsQuerySequelizeModule } from './module'; |
20 changes: 0 additions & 20 deletions
20
packages/query-typeorm/__tests__/decorators/inject-typeorm-query-service.decorator.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/query-typeorm/src/decorators/inject-typeorm-query-service.decorator.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { TypeOrmQueryService, TypeOrmQueryServiceOpts } from './services'; | ||
export { InjectTypeOrmQueryService } from './decorators'; | ||
export { NestjsQueryTypeOrmModule } from './module'; |