Querymen is a querystring parsing middleware for Express.js and MongoDB, enabling automatic pagination, sorting, field selection, and custom query filters from URL parameters. Version 2.1.4 is the current stable release, with infrequent updates. It provides a declarative schema to map query parameters to MongoDB query operators like `$gte`, `$in`, and `$exists`, and integrates with mongoose-keywords for full-text search. Compared to alternatives like express-api-query-parser, it offers a more opinionated and schema-driven approach with built-in pagination defaults.
npm install querymenVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of Querymen middleware with Express, handling pagination and sorting from query string parameters.
Access parsed data via req.querymen (e.g., req.querymen.query).
Use `{ type: Boolean }` in schema definition; query values become `true`/`false`.Define a custom schema with a `RegExp` type parameter and specify `paths` and `operator` for custom search behavior.
For other array operators (e.g., `$all`), define a custom schema with a custom formatter.
Ensure date strings are ISO 8601 compliant (e.g., '2016-04-23') to avoid parsing issues.
Ensure the middleware is applied to the route: `app.get('/posts', query(), handler)`.Use `import querymen from 'querymen'` and then `const query = querymen.middleware` or enable `esModuleInterop` in TypeScript.
Use `import { Schema } from 'querymen'` (named export) or `const { Schema } = require('querymen')`.