A lightweight, feature-rich MongoDB helper library for Node.js and TypeScript (v4.0.1). Provides a simple API for CRUD operations, pagination, transactions, aggregation, index management, and more. Supports zero-config initialization via environment variables (ERC 2.0 using nx-config2), automatic connection retry with exponential backoff, config-driven ref mapping, and signature-based deduplication. Fully typed with TypeScript, actively maintained, and distributed as an ES module package. Differentiates from Mongoose by offering a lighter, non-ODM approach with built-in pipeline-friendly features.
npm install nx-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows zero-config initialization, document insertion, and paginated query with metadata.
Migrate to ES modules or use dynamic import() (e.g., const { SimpleMongoHelper } = await import('nx-mongo')).Use new SimpleMongoHelper({ connectionString: '...', retryOptions: {...} }) for explicit configuration.Either rely on the default 'admin' database or pass the database name as the last parameter to methods like insert(data, options, dbName).
Set the required environment variable or pass configuration explicitly to the constructor.
Implement application-level retry for individual operations or use a connection pool with automatic reconnection.
Switch to ES modules (set "type": "module" in package.json) or use dynamic import(): const { SimpleMongoHelper } = await import('nx-mongo').Ensure you await initialize() before any CRUD operations: await helper.initialize(); await helper.insert(...).
Use import { SimpleMongoHelper } from 'nx-mongo'.