Registry / database / mdoq-mongodb

mdoq-mongodb

JSON →
library0.7.1jsnpmunverified

mdoq-mongodb v0.7.1 is a middleware for the mdoq library that wraps the MongoDB Node.js native driver, providing an HTTP-style API (get, post, put, del) for MongoDB operations. It allows chaining queries and modifiers like limit and sort, and supports iterators with each() to avoid buffering large result sets. Designed for simplicity, it integrates with mdoq's context and middleware system. Last updated in 2011 (no recent releases). Key differentiator: it replaces standard MongoDB driver methods with REST-like verbs, but note that mdoq and mdoq-mongodb are outdated and unmaintained.

npm install mdoq-mongodb
INSTALL
IMPORT
SIG · MDOQ-MONGODB
M
mdoq-mongodb
databasejavascriptv0.7.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.

default (middleware function)
const mdoq = require('mdoq'); const mongodbMiddleware = require('mdoq-mongodb'); mdoq.use(mongodbMiddleware);
import mongodbMiddleware from 'mdoq-mongodb'; (ESM import not supported; package is CommonJS only)
mdoq-mongodb exports a single middleware function. Use CommonJS require().
mdoq-mongodb (via require)
const mongodbMiddleware = require('mdoq-mongodb');
const { mongodbMiddleware } = require('mdoq-mongodb'); (no named exports)
The module exports a function directly. Destructuring will give undefined.
Mdoq context with MongoDB
const mdoq = require('mdoq'); const mongodbMiddleware = require('mdoq-mongodb'); const db = mdoq.use(mongodbMiddleware).use('mongodb://localhost/test-db');
const db = mdoq.use(require('mdoq-mongodb')).use('mongodb://localhost/test-db'); (technically correct but verbose; no named import needed)
Chain .use() to set the database URL after applying the middleware.

Demonstrates basic CRUD operations using mdoq-mongodb middleware with insert (POST), find (GET), update (PUT), and delete (DEL) chaining.

const mdoq = require('mdoq'); const mongodbMiddleware = require('mdoq-mongodb'); // Set up database context const db = mdoq.use(mongodbMiddleware).use('mongodb://localhost/test-db'); // Use a collection const users = db.use('/users'); // Insert a document (POST) users.post({ name: 'Alice', age: 30 }, (err, result) => { if (err) throw err; console.log('Inserted:', result); }); // Find documents (GET) with a query users.get({ age: { $gte: 25 } }, (err, results) => { if (err) throw err; console.log('Found:', results); }); // Update document (PUT) with modifier users.get({ name: 'Alice' }).put({ $inc: { age: 1 } }, (err, result) => { if (err) throw err; console.log('Updated:', result); }); // Delete document (DEL) users.del({ name: 'Bob' }, (err, result) => { if (err) throw err; console.log('Deleted:', result); });
Debug
Known issues
deprecatedmdoq-mongodb is unmaintained and relies on outdated dependencies (mdoq and mongodb native driver).
fix
Migrate to the official MongoDB Node.js driver directly or use an ODM like Mongoose.
affects: >=0.1.0
gotchaRequires mdoq to be installed; mdoq-mongodb does not include it as a dependency in npm (peer dependency missing).
fix
Install both packages: npm install mdoq mdoq-mongodb
affects: >=0.1.0
gotchaThe package exports a single function (middleware), not an object. Using destructuring will fail.
fix
Use const middleware = require('mdoq-mongodb'); without destructuring.
affects: >=0.1.0
breakingNo ESM support; cannot import with ES import syntax. May break in Node.js versions with 'type': 'module'.
fix
Use require() and avoid 'type': 'module' in package.json, or wrap with createRequire.
affects: >=0.1.0
deprecatedUses the old MongoDB native driver API (mongodb v1.x style) which is incompatible with newer MongoDB driver versions.
fix
Upgrade to modern MongoDB driver directly.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'mdoq'
mdoq is a peer dependency but not automatically installed; package.json does not declare it as a dependency.
fix
npm install mdoq
TypeError: mdoq.use(...).use is not a function
Missing mdoq installation or incorrect import; mdoq must be required before using .use().
fix
Ensure mdoq is installed: const mdoq = require('mdoq'); const mongo = require('mdoq-mongodb'); const db = mdoq.use(mongo).use('...');
Error: Cannot find module './mongo' or similar internal error
Outdated or corrupted install; mdoq-mongodb fails to resolve its internal dependencies.
fix
Reinstall: npm uninstall mdoq-mongodb && npm install mdoq-mongodb
Upgrade
Version history
0.7.1latest on npm
Audit
Dependencies
mdoqrequiredmdoq-mongodb is a middleware for mdoq and requires mdoq to be installed and used as the base context.
mongodbrequiredmdoq-mongodb wraps the MongoDB native driver; the mongodb package must be installed separately.
Agent activity
2 hits · last 30 days
node
2
Resources
mdoq-mongodb — npm install mdoq-mongodb · libregistry