INNER CODE UNIT · Python
_parse_to_bool
mongomock/mongomock · mongomock/aggregate.py:306
def _parse_to_bool(self, expression):
"""Parse a MongoDB expression and then convert it to bool"""
# handles converting `undefined` (in form of KeyError) to False
try:
return helpers.mongodb_to_bool(self.parse(expression))
except KeyError:
return False
def _parse_or_nothing(self, expression):
try:
return self.parse(expression)
except KeyError:
return NOTHING
def _parse_basic_expression(self, expression):
if isinstance(expression, str) and expression.startswith('$'):
if expression.startswith('$$'):
return helpers.get_value_by_dot(