{"id":44093,"library":"unified-mongo-filter","title":"Unified Mongo Filter","description":"A lightweight utility for applying MongoDB-like query filters (e.g., $eq, $gte, $in, $regex) to plain JavaScript objects. Version 0.4.0 is current, with stable API and low release cadence. Key differentiator: no database dependency, pure in-memory filtering. Supports nested fields, dot notation, and most MongoDB operators.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install unified-mongo-filter","lang":"bash","label":"npm"},{"cmd":"yarn add unified-mongo-filter","lang":"bash","label":"yarn"},{"cmd":"pnpm add unified-mongo-filter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require will fail. Use dynamic import if needed.","wrong":"const { matches } = require('unified-mongo-filter')","symbol":"matches","correct":"import { matches } from 'unified-mongo-filter'"},{"note":"createValidator is a named export, not default.","wrong":"import createValidator from 'unified-mongo-filter'","symbol":"createValidator","correct":"import { createValidator } from 'unified-mongo-filter'"},{"note":"Library does not export a default; this import will be undefined.","wrong":"import { default as unifiedMongoFilter } from 'unified-mongo-filter'","symbol":"default","correct":"import unifiedMongoFilter from 'unified-mongo-filter'"}],"quickstart":{"code":"import { matches } from 'unified-mongo-filter';\n\nconst filter = { $or: [{ age: { $gte: 18 } }, { role: 'admin' }] };\n\nconst users = [\n  { name: 'Alice', age: 20, role: 'user' },\n  { name: 'Bob', age: 17, role: 'admin' },\n  { name: 'Charlie', age: 15, role: 'user' }\n];\n\nconst filtered = users.filter(user => matches(user, filter));\nconsole.log(filtered);\n// [{ name: 'Alice', age: 20, role: 'user' }, { name: 'Bob', age: 17, role: 'admin' }]","lang":"typescript","description":"Filters an array of objects using a MongoDB-style query with $or and $gte operators."},"warnings":[{"fix":"Use new RegExp('pattern', 'flags') or string '/pattern/flags'.","message":"Operator $regex expects a RegExp object or string; flags must be embedded in string like '/pattern/flags'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure filter keys use dot path for nested fields, e.g., 'address.city'.","message":"Nested field access uses dot notation; 'a.b' will not match {a: {b: 1}} if value is array?","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Validate field is array before applying $elemMatch.","message":"Using $elemMatch with non-array field returns undefined?","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use {$exists: false} for missing keys, not $ne: null.","message":"Null comparison: {$eq: null} works but {$ne: null} may not match missing keys.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.4.0':24 'api':29 'appli':8 'cadenc':33 'current':26 'databas':37 'depend':38 'differenti':35 'dot':47 'e.g':14 'eq':15 'field':46 'filter':3,13,43 'gte':16 'in-memori':40 'javascript':21,53 'key':34 'lightweight':5 'like':11 'low':31 'memori':42 'mongo':2 'mongodb':10,51 'mongodb-lik':9 'nest':45 'notat':48 'object':22 'oper':52 'plain':20 'pure':39 'queri':12 'regex':18 'releas':32 'stabl':28 'support':44 'unifi':1 'util':6 'version':23","created_at":"2026-06-05T17:02:56.525416+00:00","updated_at":"2026-06-05T17:02:56.525416+00:00","problems":[{"fix":"Use import { matches } from 'unified-mongo-filter' or dynamic import.","cause":"CommonJS require used; ESM-only package.","error":"TypeError: matches is not a function"},{"fix":"Ensure filter values are objects with operator keys, e.g., { age: { $gte: 18 } }.","cause":"Filter object malformed; nested operator not in expression format.","error":"Uncaught TypeError: Cannot read properties of undefined (reading '$gte')"},{"fix":"Use only supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $regex, $exists, $type, $elemMatch, $and, $or, $not, $nor, $where, $expr.","cause":"Unsupported custom operator used.","error":"Error: Invalid filter operator: $custom"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"unified-mongo-filter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}