Registry / database / monk-middleware-query

monk-middleware-query

JSON →
library0.2.0jsnpmunverified

monk-middleware-query is a middleware for the Monk MongoDB library (version 0.2.0) that parses and transforms query objects. It allows you to define query processing logic that runs before database operations, such as modifying or validating query conditions. This package is part of the Monk ecosystem and is intended to be used with Monk's middleware pipeline. It is stable but minimally documented, with no recent updates. Key differentiator: it provides a structured way to intercept and manipulate queries in Monk applications.

npm install monk-middleware-query
INSTALL
IMPORT
SIG · MONK-MIDDLEWARE-QU
M
monk-middleware-query
databasejavascriptv0.2.0
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 query from 'monk-middleware-query'
const { query } = require('monk-middleware-query')
The module exports a function as the default export. Use default import for ESM. CommonJS users should use require('monk-middleware-query').default or import * as q from 'monk-middleware-query'.
Middleware
import query from 'monk-middleware-query'
import { query } from 'monk-middleware-query'
There is no named export; the entire module is a single function. Attempting a named import will result in undefined.
monk instance .use
db.use(require('monk-middleware-query')())
db.use('monk-middleware-query')
The middleware must be required/imported and called as a function (optionally with options) before being used with .use(). Passing the string will not work.

Demonstrates how to import and apply the query middleware to a Monk database instance.

import monk from 'monk'; import queryMiddleware from 'monk-middleware-query'; const db = monk('localhost/mydb'); db.use(queryMiddleware()); const users = db.get('users'); // With middleware, you can transform queries: for example, enforce a filter // The middleware processes the query before it reaches the database. const docs = await users.find({ age: { $gt: 20 } }); console.log(docs);
Debug
Known issues
gotchaThe middleware must be called as a function (e.g., queryMiddleware()) before passing to .use(), not just passed as a reference.
fix
Use db.use(queryMiddleware()) instead of db.use(queryMiddleware).
affects: >=0.1.0
gotchaThis package is deprecated or not actively maintained. It may not work with newer versions of Monk (>=7.0.0) due to breaking changes in Monk's middleware API.
fix
Consider using Monk's built-in middleware or another middleware package compatible with your Monk version.
affects: >=7.0.0
gotchaThe package has no README or documentation. Understanding its behavior requires reading the source code.
fix
Refer to the GitHub source for usage details.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: db.use is not a function
Using the middleware before initializing the Monk database connection.
fix
Ensure db is a Monk database instance (e.g., const db = monk('uri')) before calling db.use().
Cannot find module 'monk-middleware-query'
The package is not installed or the import path is incorrect.
fix
Run npm install monk-middleware-query and verify the import statement.
Middleware must be a function
Passing the middleware module directly instead of calling it as a function.
fix
Use db.use(queryMiddleware()) instead of db.use(queryMiddleware).
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
monkrequiredmonk-middleware-query is a middleware plugin for Monk and requires Monk to function.
Agent activity
2 hits · last 30 days
node
2
Resources
monk-middleware-query — npm install monk-middleware-query · libregistry