AdonisJS provider to integrate MongoDB into AdonisJS applications using the official MongoDB Node.js driver. Version 1.0.0 is the latest stable release, compatible with @adonisjs/fold ^4.0.9 and mongodb ^3.3.5. This package provides a simple way to register MongoDB as a service provider in AdonisJS, allowing dependency injection of a MongoDB client instance throughout the app. It is a lightweight alternative to full-featured ODM libraries like Mongoose, targeting developers who prefer the native driver within AdonisJS. The project is maintained but has limited community adoption and documentation.
npm install adonis-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows provider registration and basic usage to query a MongoDB collection.
Do not call client.close() – let the provider manage connection lifecycle.
If using AdonisJS 5, consider using @adonisjs/lucid with MongoDB adapter or adonis5-mongodb.
Append pool options to MONGODB_URL, e.g., mongodb://localhost:27017/myapp?maxPoolSize=10
Ensure your project uses the specified peer dependency versions.
Run `adonis install adonis-mongodb` and verify the provider path is exactly 'adonis-mongodb/providers/MongoProvider'
Use() is only available within AdonisJS controllers, services, etc. For external scripts, require the IoC container.
Set MONGODB_URL in .env file and restart the server.