clixiya-apifeatures
v1.0.0
Published
Chainable Mongoose query and aggregate helper for filtering, sorting, pagination, search, and more.
Maintainers
Readme
apifeatures-query-helper
Chainable Mongoose query and aggregate helper for backend APIs.
What this package gives you
- Filtering with whitelist support and operator parsing
- Sorting and projection helpers
- Safe pagination and metadata
- Regex/text search helpers
- Geo filtering helpers
- Aggregate pipeline helpers
- Parallel data + count execution
Install
npm install apifeatures-query-helperUsage (ESM)
import APIFeatures from 'apifeatures-query-helper';
const { data, meta } = await APIFeatures
.create(Product.find(), req.query)
.filter(['name', 'price', 'category'])
.search(['name', 'description'])
.sortData('-price')
.limitFields('name', 'price', 'slug')
.paginate(50)
.lean()
.exec({ getCount: true });Usage (CommonJS)
const APIFeatures = require('apifeatures-query-helper');
const { data, meta } = await APIFeatures
.create(Product.find(), req.query)
.filter(['name', 'price'])
.paginate(100)
.exec({ getCount: true });Local build
npm install
npm run buildPublish to npm
- Update the package name in package.json if needed.
- Bump version in package.json.
- Login to npm:
npm login- Publish:
npm publishFor scoped packages, publish as public:
npm publish --access public