dictutils.ops.matchΒΆ

dictutils.ops.match(items, **eq)[source]ΒΆ

Match items by exact field values using dot-path notation.

Parameters:
  • items (Iterable[Any]) – Collection to search

  • **eq (Any) – Field paths and expected values

Return type:

list[Any]

Returns:

List of items matching all criteria

Example

>>> import json
>>> users = [
...     {"name": "Alice", "profile": {"role": "admin", "active": True}},
...     {"name": "Bob", "profile": {"role": "user", "active": True}},
...     {"name": "Carol", "profile": {"role": "admin", "active": False}}
... ]
>>> result = match(users, **{"profile.role": "admin", "profile.active": True})
>>> print(json.dumps(result, indent=4))
[
    {
        "name": "Alice",
        "profile": {
            "role": "admin",
            "active": true
        }
    }
]