The official MongoDB driver for Node.js, maintained by MongoDB Inc. This package (version 4.10.100) provides async/await support, transaction support, and a modern API for connecting to MongoDB databases. It ships TypeScript types and requires Node.js >= 12.9.0. Key differentiators include full support for MongoDB features like change streams, aggregation, and gridfs, as well as automatic connection pooling and retryable reads/writes. The driver follows MongoDB's release cadence and is actively developed.
npm install qh-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to MongoDB, inserts a document, and retrieves it using async/await.
Add await client.connect() before any db operations.
Use ObjectId from 'mongodb' instead of ObjectID.
Always call client.close() in a finally block or use the with statement pattern.
Install optional dependency: npm install mongodb-client-encryption.
Use async/await or .then() instead of callbacks.
Use insertOne/insertMany, updateOne/updateMany, deleteOne/deleteMany instead.
Start MongoDB service: `mongod` or `net start MongoDB` on Windows.
Remove `useNewUrlParser: true` from the MongoClient options.
Add `await client.connect();` before using `client.db()`.
Check username/password in the connection string and ensure the database user exists.