Skip to content

Commit

Permalink
Change string to symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Melikhov committed Apr 6, 2020
1 parent d38ec28 commit ef7cbbc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nest-di/src/di/di.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { join } from "path";
import { Product } from './product/product.entity';
import { UserService } from './user/user.service';

const PRODUCT_REPOSITORY = Symbol('ProductRepository');

const options: ConnectionOptions = {
type: "sqlite",
database: join(__dirname, '..', '..', 'data', 'di.sqlite'),
Expand All @@ -18,7 +20,7 @@ const options: ConnectionOptions = {
providers: [
UserService,
{
provide: 'ProductRepository',
provide: PRODUCT_REPOSITORY,
useFactory: async () => {
const connection = await createConnection(options);
return connection.getRepository(Product);
Expand All @@ -29,7 +31,7 @@ const options: ConnectionOptions = {
useFactory: (productRepository, userService) => {
return new ProductService(productRepository, userService)
},
inject: ['ProductRepository', UserService]
inject: [PRODUCT_REPOSITORY, UserService]
}
]
})
Expand Down

0 comments on commit ef7cbbc

Please sign in to comment.