Registry / database / npm.mongo

npm.mongo

JSON →
library3.0.8jsnpmunverified

npm.mongo is a beginner-friendly MongoDB wrapper for Node.js, designed as a key-value store with an API similar to quick.db. Version 3.0.8 (stable) provides asynchronous operations, dot notation support, and multiple model support. It simplifies MongoDB for novices but lacks TypeScript types, has limited community traction, and is primarily used in Discord bot development. Compared to Mongoose or native MongoDB driver, it sacrifices flexibility for simplicity.

npm install npm.mongo
INSTALL
IMPORT
SIG · NPM.MONGO
N
npm.mongo
databasejavascriptv3.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Database
✓ const { Database } = require('npm.mongo');
✗ import { Database } from 'npm.mongo';
This package does not support ESM import syntax. Use CommonJS require().
Database
✓ const { Database } = require('npm.mongo');
✗ const Database = require('npm.mongo').Database;
Destructured require is the correct pattern as the package exports an object with Database.
new Database()
✓ const db = new Database('mongodb://localhost/npm.mongo');
✗ const db = new Database();
A MongoDB connection URI is required in the constructor; omitting it will cause a connection error.

Shows how to connect to MongoDB, set a key-value pair, and retrieve it asynchronously using the Database class.

const { Database } = require('npm.mongo'); const db = new Database('mongodb://localhost/npm.mongo'); db.on('ready', async () => { console.log('Database connected!'); await db.set('foo', 'bar'); const value = await db.get('foo'); console.log(value); // 'bar' process.exit(0); });
Debug
Known issues
breakingConstructor now requires a MongoDB connection URI; previous versions may have worked with an empty constructor.
fix
Pass a valid MongoDB URI string to new Database(uri).
affects: >=3.0.0
gotchaAll Database methods return Promises; forgetting to await can lead to race conditions.
fix
Use await or .then() on methods like set(), get(), push(), add().
affects: >=1.0.0
gotchaThe package does not export as ESM; using import will break.
fix
Use require() instead of import.
affects: >=1.0.0
deprecatedThe package appears to be a personal fork of quick.db functionality with limited updates.
fix
Consider using the original quick.db or mongodb driver for better maintenance.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'Database' of 'require(...)' as it is undefined.
Package not installed or module path incorrect.
fix
Run npm install npm.mongo and ensure the require path is 'npm.mongo'.
MongooseError: The uri parameter to openUri() must be a string, got 'undefined'
Database constructor called without a MongoDB URI.
fix
Provide a valid MongoDB connection string: const db = new Database('mongodb://localhost:27017/mydb');
TypeError: db.set is not a function
Forgot to instantiate Database or used wrong import pattern.
fix
Ensure you have const { Database } = require('npm.mongo'); and const db = new Database(uri);
Upgrade
Version history
3.0.8latest on npm
Audit
Dependencies
mongooserequiredMongoose is the underlying MongoDB ODM that npm.mongo wraps; required at runtime.
Agent activity
14 hits · last 30 days
node
6
Resources
npm.mongo — npm install npm.mongo · libregistry