Registry / database / quick.mongodb

quick.mongodb

JSON →
library1.0.1jsnpmunverified

A beginner-friendly key-value MongoDB wrapper that mimics the quick.db API. Version 1.0.1 is current with a moderate release cadence. It provides asynchronous dot-notation access, import/export from quick.db, and multiple model support. Differentiated by its simplicity and similarity to quick.db, making it easy for those already familiar with quick.db to switch to MongoDB. Ships TypeScript definitions.

npm install quick.mongodb
INSTALL
IMPORT
SIG · QUICK.MONGODB
Q
quick.mongodb
databasejavascriptv1.0.1
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('quick.mongodb');
const Database = require('quick.mongodb');
Database is a named export, not default. For ESM: import { Database } from 'quick.mongodb';
Database
import { Database } from 'quick.mongodb';
import Database from 'quick.mongodb';
Default import does not exist; must use named import in ESM.
Database
const { Database } = require('quick.mongodb');
const { Database } = await import('quick.mongodb');
Dynamic import also works but is uncommon; static import/require is preferred.

Shows basic setup with connection string, ready event, and set/get operations.

const { Database } = require('quick.mongodb'); const db = new Database('mongodb://localhost:27017/mydb'); db.on('ready', () => { console.log('Connected'); db.set('key', 'value').then(() => { db.get('key').then(console.log); }); }); db.on('error', console.error);
Debug
Known issues
gotchaDatabase methods are asynchronous and return promises; forgetting to await/then can lead to race conditions.
fix
Always handle promises with .then() or await in async functions.
affects: all
gotchaThe 'ready' event may fire before or after operations are queued; ensure DB is connected before first call.
fix
Wrap initial operations inside the 'ready' callback or use db.ready() promise.
affects: all
gotchaDot notation like 'user.info.name' works but nested objects must exist; otherwise it creates the path.
fix
Use db.set('user', {}) first if you need to ensure nesting exists.
affects: all
gotchaThe package uses Mongoose internally; you cannot use the same connection elsewhere without sharing.
fix
If you need multiple connections, create separate Database instances.
affects: all
Errors
Common errors & fixes
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
No connection string provided to Database constructor or it's undefined.
fix
Ensure you pass a valid MongoDB URI: new Database('mongodb://...')
TypeError: db.get is not a function
Database is imported incorrectly, e.g., default import instead of named import.
fix
Use const { Database } = require('quick.mongodb'); (named destructuring)
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
Calling a method that returns undefined instead of a promise, often because DB not connected.
fix
Wait for 'ready' event or use db.ready() before calling methods.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
mongooserequiredUnderlying MongoDB ODM used for database operations
Agent activity
9 hits · last 30 days
node
8
Meta
1
Resources
quick.mongodb — npm install quick.mongodb · libregistry