Hapi.js plugin that automatically parses URL query parameters into MongoDB/Mongoose query objects. Current stable version is 2.2.0, with a release cadence (latest update Oct 2023). It supports pagination, sorting, field selection, search ($q), and conditional operators. Unlike similar libraries, it tightly integrates with Hapi (v21+) and exposes parsed queries directly on `request.parsedQuery`. Requires Node >=18.20.1 and @hapi/hapi >=21.x.x.
npm install hapi-query-builderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Registers hapi-query-builder plugin, sets defaultSelectField, and creates a route that returns parsed MongoDB query from URL params.
Upgrade Node to >=18.20.1 and @hapi/hapi to >=21.x.x.
Ensure your query-building routes are GET only.
Avoid nested field references in $select. Use a flat field list.
Always provide a defaultSelectField (commonly '_id') to avoid empty select.
Ensure correct delimiter: pipe separates search term from fields, commas separate multiple fields.
Use `require('hapi-query-builder')` and pass at least empty options: `options: {}`.Upgrade @hapi/hapi to version 21 or higher.
Ensure `await server.register(...)` is called before adding routes.
Use format `$or=field1|value1,field2|value2`.