def convert()

in modular_sdk/models/pynamodb_extension/pynamodb_to_pymongo_adapter.py [0:0]


    def convert(cls, condition: Condition) -> dict:
        op = condition.operator
        if op == 'OR':
            return {
                '$or': [cls.convert(cond) for cond in condition.values]
            }
        if op == 'AND':
            return {
                '$and': [cls.convert(cond) for cond in condition.values]
            }
        if op == 'NOT':
            return {
                '$nor': [cls.convert(condition.values[0])]
            }
        if op == 'attribute_exists':
            return {
                cls.path_to_raw(condition.values[0]): {'$exists': True}
            }
        if op == 'attribute_not_exists':
            return {
                cls.path_to_raw(condition.values[0]): {'$exists': False}
            }
        if op == 'contains':
            return {
                cls.path_to_raw(condition.values[0]): {
                    '$regex': cls.value_to_raw(condition.values[1])
                }
            }
        if op == 'IN':
            return {
                cls.path_to_raw(condition.values[0]): {
                    '$in': list(
                        cls.value_to_raw(v) for v in
                        islice(condition.values, 1, None)
                    )
                }
            }
        if op == '=':
            return {
                cls.path_to_raw(condition.values[0]): cls.value_to_raw(
                    condition.values[1])
            }
        if op in cls.comparison_map:
            _mongo_op = cls.comparison_map[op]
            return {
                cls.path_to_raw(condition.values[0]): {
                    _mongo_op: cls.value_to_raw(condition.values[1])
                }
            }
        if op == 'BETWEEN':
            return {
                cls.path_to_raw(condition.values[0]): {
                    '$gte': cls.value_to_raw(condition.values[1]),
                    '$lte': cls.value_to_raw(condition.values[2])
                }
            }
        if op == 'begins_with':
            return {
                cls.path_to_raw(condition.values[0]): {
                    '$regex': f'^{cls.value_to_raw(condition.values[1])}'
                }
            }
        raise NotImplementedError(f'Operator: {op} is not supported')