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);
});
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.
TypeError: mdoq.use(...).use is not a function
Missing mdoq installation or incorrect import; mdoq must be required before using .use().
fixEnsure 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.
fixReinstall: npm uninstall mdoq-mongodb && npm install mdoq-mongodb
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.