A NestJS module that integrates the official MongoDB Node.js driver (not Mongoose) into NestJS applications, providing dependency injection for Db and Collection objects. Version 6.4.0 supports NextJS 6-10 and TypeScript 5 decorators. This is a fork of the original erikc5000/nest-mongodb, updated to support TypeScript 5 decorator syntax, which the original maintainer has not yet published. Differentiates from the Mongoose module by offering lower-level MongoDB driver access without schema/models.
npm install nest-mongodb-ts5No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows async configuration with MongoModule.forRootAsync and usage of @InjectDb decorator to inject the MongoDB Db instance.
Upgrade TypeScript to >=5.0.0 and ensure experimentalDecorators is false.
Pass options as third parameter, not as part of uri string.
Always pass a non-empty string to @InjectCollection().
Use MongoModule.forRootAsync() for dynamic configuration.
Import Db from 'mongodb' top-level package.
npm install nest-mongodb mongodb
Add 'import 'reflect-metadata'' at top of main entry file.
Ensure MongoModule.forRoot() or forRootAsync() is called in a module imported by the root module.
Use result.acknowledged to check success and result.insertedId for inserted ID.
Set 'type': 'module' in package.json or use dynamic import().