Converts a json-mask pattern (e.g., 'id,name,address(city)') into a MongoDB projection object for field inclusion/exclusion. v1.1.0 is the latest stable version; sporadic updates. Key differentiator: enables dynamic projection based on client query parameters, simplifying REST API field filtering for MongoDB queries. No runtime dependencies.
npm install mongo-maskNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to convert a json-mask pattern to a MongoDB projection object, with optional field mapping.
Ensure pattern selects only fields to include or only fields to exclude; do not mix unless for _id.
The conversion handles parentheses to dot notation automatically.
Map only top-level fields; for nested, map the parent and handle individually.
Use `const mongoMask = require('mongo-mask')` or `import mongoMask from 'mongo-mask'`.Ensure pattern includes only fields to include (e.g., 'a,b,c') or only fields to exclude (e.g., '-a,-b,-c'), not both.
Verify pattern syntax: e.g., 'field1,field2(nested)' is valid; 'field1,field2(' is invalid.No dependency data recorded yet.