INNER CODE UNIT · Python

__init__

mongomock/mongomock · mongomock/aggregate.py:233

    def __init__(self, doc_dict, user_vars=None, ignore_missing_keys=False):
        self._doc_dict = doc_dict
        self._ignore_missing_keys = ignore_missing_keys
        self._user_vars = user_vars or {}

    def parse(self, expression):
        """Parse a MongoDB expression."""
        if not isinstance(expression, dict):
            # May raise a KeyError despite the ignore missing key.
            return self._parse_basic_expression(expression)

        if len(expression) > 1 and any(key.startswith('$') for key in expression):
            raise OperationFailure(
                f'an expression specification must contain exactly one field, '
                f'the name of the expression. Found {len(expression)} fields in {expression}'
            )

        value_dict = {}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…