Generic Data Access Object for MongoDB that simplifies CRUD operations with a class-based API. Version 2.0.2, released in 2019, is the latest stable version. It wraps the native MongoDB driver to provide pagination, sorted queries, and formatted output. Compared to lower-level drivers, it reduces boilerplate but lacks active updates and TypeScript support. The package is ES6-native and uses the native MongoDB driver as a peer dependency.
npm install mongodb-dao-es6No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to MongoDB, creates a DAO, performs create, find (with filter), and delete operations.
Assign values to `dao.match`, `dao.id` etc. before each operation.
Remove these options if using mongodb driver 4.0+; they are now default.
Expect an array from `dao.create(data)`; access first element if needed.
Use `const BaseDao = require('mongodb-dao-es6').default` or switch to ESM `import`.Consider using a more actively maintained DAO like `mongodb-dao` or the native driver directly.
Always provide `dbName` and `collection` in config.
Use `const BaseDao = require('mongodb-dao-es6').default` for CJS or switch to ESM import.Ensure config.collection is a non-empty string.
Await `client.connect()` before creating BaseDao instance.
Set `dao.id` to a valid ObjectId or document _id before calling update/delete.