Registry / database / devextreme-parse-filter-for-mongodb

devextreme-parse-filter-for-mongodb

JSON →
library1.0.5jsnpmunverified

A utility that converts DevExtreme dxDataGrid filter expressions into MongoDB aggregation pipeline $match stages. Version 1.0.5 is the latest stable release. It supports string-based date conversion and handles complex nested filters with AND/OR combinations. Unlike manual parsing, it automates the translation of the DevExtreme filter format to MongoDB query syntax, reducing boilerplate for applications that use both DevExtreme grids and MongoDB.

npm install devextreme-parse-filter-for-mongodb
INSTALL
IMPORT
SIG · DEVEXTREME-PARSE-F
D
devextreme-parse-filter-for-mongodb
databasejavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parseFilter
✓ const parseFilter = require('devextreme-parse-filter-for-mongodb')
✗ import parseFilter from 'devextreme-parse-filter-for-mongodb'
Package is CommonJS only; ESM import may not work.
parseFilter
✓ import parseFilter = require('devextreme-parse-filter-for-mongodb')
TypeScript users should use import = require for CommonJS.
parseFilter
✓ const parseFilter = require('devextreme-parse-filter-for-mongodb').default
✗ const parseFilter = require('devextreme-parse-filter-for-mongodb').parseFilter
The package exports a single function as module.exports, so require returns it directly; no .default needed.

Parses a DevExtreme dxDataGrid filter string into a MongoDB aggregation pipeline array with $match operators.

const parseFilter = require('devextreme-parse-filter-for-mongodb'); const filter = '[["dateUpdated",">=","2017-05-16T16:00:00.000Z"],"and",["dateUpdated","<","2017-05-17T16:00:00.000Z"]]'; const aggregate = parseFilter(filter); console.log(JSON.stringify(aggregate, null, 2));
Debug
Known issues
gotchaPassing an invalid filter string will result in an unhandled error.
fix
Wrap parseFilter call in try-catch or validate filter input before passing.
affects: >=0.0.0
gotchaDate keys must be provided manually to convert string dates to Date objects.
fix
Provide date keys as additional arguments: parseFilter(filter, 'dateUpdated', 'createdAt').
affects: >=0.0.0
gotchaThe package is CJS-only; ESM imports using `import` may fail.
fix
Use require or set up a bundler that handles CJS.
affects: >=0.0.0
gotchaFilter must be passed as a string; objects are not accepted.
fix
Convert filter object to JSON string before passing.
affects: >=0.0.0
gotchaThe returned pipeline only contains $match stages; it does not handle sorting, pagination, or projection.
fix
Append additional stages (e.g., $sort, $skip, $limit) to the pipeline as needed.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: parseFilter is not a function
Importing the package incorrectly, e.g., using ES import syntax or destructuring.
fix
Use const parseFilter = require('devextreme-parse-filter-for-mongodb');
SyntaxError: Unexpected token u in JSON at position 0
Passing undefined or null as filter argument.
fix
Ensure filter is a valid JSON string before calling parseFilter.
TypeError: dateKeys.filter is not a function
Passing date keys as a single array instead of spread arguments.
fix
Use parseFilter(filter, ...dateKeysArray) instead of parseFilter(filter, dateKeysArray).
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
devextreme-parse-filter-for-mongodb — npm install devextreme-parse-filter-for-mongodb · libregistry