INNER CODE UNIT · Python
_handle_project_operator
mongomock/mongomock · mongomock/aggregate.py:429
def _handle_project_operator(self, operator, values):
if operator in _GROUPING_OPERATOR_MAP:
values = self.parse(values) if isinstance(values, str) else self.parse_many(values)
return _GROUPING_OPERATOR_MAP[operator](values)
if operator == '$arrayElemAt':
key, value = values
array = self.parse(key)
index = self.parse(value)
try:
return array[index]
except IndexError as error:
raise KeyError('Array have length less than index value') from error
raise NotImplementedError(
f"Although '{operator}' is a valid project operator for the "
f'aggregation pipeline, it is currently not implemented '
f'in Mongomock.'
)