{"id":24066,"library":"mongoquery","title":"mongoquery","description":"A utility library that provides a MongoDB-like query language for querying Python collections, especially lists of dicts from JSON or YAML parsers. Current version is 1.4.3. Releases are infrequent; the last release was around 2019.","status":"maintenance","version":"1.4.3","language":"python","source_language":"en","source_url":"http://github.com/kapouille/mongoquery","tags":["mongodb","query","json","yaml","filter"],"install":[{"cmd":"pip install mongoquery","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The main class is Query; importing the module alone requires mongoquery.Query.","wrong":"import mongoquery","symbol":"Query","correct":"from mongoquery import Query"}],"quickstart":{"code":"from mongoquery import Query\n\nitems = [\n    {'name': 'Alice', 'age': 30},\n    {'name': 'Bob', 'age': 25},\n    {'name': 'Charlie', 'age': 35}\n]\n\nq = Query({'age': {'$gte': 30}})\nresult = q.match(items)\nprint(result)  # [{'name': 'Alice', 'age': 30}, {'name': 'Charlie', 'age': 35}]","lang":"python","description":"Basic usage: create a Query with a MongoDB-like filter and call .match() on a list of dicts."},"warnings":[{"fix":"Use re.compile(r'pattern') directly as a value, or use string with '$regex' key in dict structure.","message":"Version 1.4.0 changed how compiled regexes are supplied: they must be compiled regex objects (not strings with $regex) when using $regex operator.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"Ensure input data is a list of dicts-like structures. For objects, use __dict__ or convert to dict first.","message":"The library only matches against lists of dicts (or similar nested structures). It does not operate on arbitrary Python objects or ORM models.","severity":"gotcha","affected_versions":"all"},{"fix":"Review MongoDB documentation for $elemMatch semantics and test with your data.","message":"Operators like $elemMatch may behave unexpectedly if the array contains objects with extra keys; matching is done against each element entirely.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Wrap single dict in a list: q.match([my_dict]) or use q.match(my_dict) only if my_dict is itself a list.","cause":"Calling .match() incorrectly expects an iterable of dicts, but a single dict was passed.","error":"TypeError: 'Query' object is not iterable"},{"fix":"For regex matching, use compiled regex: q = Query({'field': re.compile(r'pattern')}) or use dict: q = Query({'field': {'$regex': 'pattern'}}).","cause":"A string was passed where a dict was expected (e.g., using $regex as a value without proper operator syntax).","error":"AttributeError: 'str' object has no attribute 'items'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}