我正在使用express.js和typeorm。我想创建BookRepository,它将是扩展typeorm仓库的自定义仓库。
import { Repository } from 'typeorm';
import { AppDataSource } from '..';
import { provideSingleton } from '../common/utils/ProvideSingleton';
import { Book } from './Book';
@provideSingleton(BookRepository)
export class BookRepository extends Repository<Book> {
constructor() {
super(Book, AppDataSource.manager, AppDataSource.createQueryRunner());
}
}
但当我点击激活控制器-〉服务-〉存储库的路径时,我得到以下错误:
Error: The number of constructor arguments in the derived class BookRepository must be >= than the number of constructor arguments of its base class.
不确定我做错了什么,因为typeorm Repository类有3个参数,最后一个是可选的:
constructor(target: EntityTarget<Entity>, manager: EntityManager, queryRunner?: QueryRunner);
1条答案
按热度按时间6ie5vjzr1#
provideSingleton
装饰器向BookRepository
的构造函数添加了一个额外的参数,这导致了您提到的错误。