Как правильно работать с Mon goose и GridFS?
Я пытаюсь добавить Mongodb Gridfs в Nest JS Пример 14 (https://github.com/nestjs/nest/tree/master/sample/14-mongoose-base)
Но когда я использую тег @InjectConnection:
// files.service.ts
private readonly fileModel: MongoGridFS;
constructor(@InjectConnection() private readonly connection: Connection) {
this.fileModel = new MongoGridFS(this.connection.db, 'fs');
}
async readStream(id: string): Promise<GridFSBucketReadStream> {
return await this.fileModel.readFileStream(id);
}
Произошла следующая ошибка:
[Nest] 24282 - 04/20/2020, 4:10:23 PM [ExceptionHandler] Nest can't resolve dependencies of the FilesService (?). Please make sure that the argument DatabaseConnection at index [0] is available in the FilesModule context.
Potential solutions:
- If DatabaseConnection is a provider, is it part of the current FilesModule?
- If DatabaseConnection is exported from a separate @Module, is that module imported within FilesModule?
@Module({
imports: [ /* the Module containing DatabaseConnection */ ]
})
Error: Nest can't resolve dependencies of the FilesService (?). Please make sure that the argument DatabaseConnection at index [0] is available in the FilesModule context.