A composable schema extension for schm that parses query parameters into MongoDB queries, projections, and pagination. Version 0.4.1 is the latest stable release; the project appears to be in maintenance mode with no updates since 2018. It integrates with schm to define field projections via the `fields` parser, pagination via `page` with sort/limit/skip, geospatial queries via `near`, and operator-based filtering via `query`. Unlike monolithic ODM libraries, it provides lightweight, composable schema functions that work directly with the MongoDB Node.js driver or Mongoose.
npm install schm-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates parsing query parameters, field projections, and pagination using schm-mongo with the schm schema library.
Consider alternatives like @hapi/joi with custom MongoDB transformers or mongoose for full ODM support.
Ensure schema fields that should become MongoDB operators have `operator` set, e.g., `{ type: Date, operator: '$gte' }`.Always specify fields to avoid unintended projection. Use `fields: ['-_id', 'name']` to hide `_id`.
Pass numeric strings like '1' and '10' as query params; the parser handles conversion.
Supply coordinates as 'lat,lng' string. Remember GeoJSON order is [longitude, latitude].
Run `npm install schm@^0.4.0` alongside schm-mongo.
Use `const schema = require('schm')` (CommonJS) or `import schema from 'schm'` (ESM).Use `import { query } from 'schm-mongo'` or `const { query } = require('schm-mongo')`.