Registry / database / monk-middleware-options

monk-middleware-options

JSON →
library0.2.1jsnpmunverified

A middleware plugin for Monk (a MongoDB driver) that parses options passed to collection methods. It currently supports the 'safe' option and is intended for use with Monk v7 and earlier. The package is part of the Monk middleware ecosystem and has not been actively developed, with the last release (0.2.1) occurring alongside Monk v4. For modern Monk versions (v7+), option parsing is handled internally or via other middleware such as monk-middleware-cast-ids.

npm install monk-middleware-options
INSTALL
IMPORT
SIG · MONK-MIDDLEWARE-OP
M
monk-middleware-options
databasejavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import options from 'monk-middleware-options'
const options = require('monk-middleware-options')
The package exposes a default export function. CommonJS require works with default exports in this package.
options
const options = require('monk-middleware-options')
const { options } = require('monk-middleware-options')
The package exports a single function as default; destructuring will result in undefined.
options
import options from 'monk-middleware-options'
import { options } from 'monk-middleware-options'
This is a default export; named import syntax will not work.

Demonstrates basic usage: requiring monk, applying the options middleware to a collection, and using the 'safe' option.

const monk = require('monk'); const options = require('monk-middleware-options'); // Use with Monk's collection middleware const db = monk('localhost/mydb'); const users = db.get('users', { castIds: false }); users.use(options()); // Now the 'safe' option will be parsed users.insert({ name: 'John' }, { safe: true }).then(doc => { console.log('Inserted:', doc); }).catch(err => { console.error(err); });
Debug
Known issues
deprecatedThe 'safe' option is deprecated in MongoDB driver 3.0 and later.
fix
Use writeConcern instead. For Monk v7+, writeConcern is automatically set via connection URI or driver options.
affects: >=7.0.0
gotchaThis middleware only parses the 'safe' option; other options (e.g., writeConcern) are not handled.
fix
Use monk-middleware-cast-ids or handle other options manually.
affects: >=0.0.0
breakingMonk v6 removed the middleware option parsing mechanism; monk-middleware-options is no longer needed.
fix
Remove usage of this middleware; options are now passed directly to Monk methods.
affects: >=6.0.0
Errors
Common errors & fixes
TypeError: db.get(...).use is not a function
Monk v6+ no longer supports .use() for middleware; middleware API was removed.
fix
Upgrade to Monk v6+ and remove calls to .use(). Options are passed directly to methods.
Error: options.safe is not a function
The 'safe' option is deprecated and should be replaced with writeConcern.
fix
Use writeConcern instead: { writeConcern: { w: 1 } }.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
monkoptionalPeer dependency; this middleware is designed to be used with Monk and expects Monk's collection API.
Agent activity
6 hits · last 30 days
node
6
Resources
monk-middleware-options — npm install monk-middleware-options · libregistry