def pull(self, expr, *args, **kwargs): import expression_parser _data = expression_parser.to_mongobd_match(expr, *args, **kwargs) if self.__data__ == None: self.__data__ = {} self.__data__.update({"$pull": _data}) return self
def __init__(self, expr, *args, **kwargs): import pydocs import expression_parser if isinstance(expr, pydocs.Fields): self.__stage__ = pydocs.get_field_expr(expr, True) elif type(expr) in [str, unicode]: self.__stage__ = expression_parser.to_mongobd_match( expr, *args, **kwargs)
def where(self, expr, *args, **kwargs): # type:()->pycollection.entity if type(expr) is [str, unicode]: return pycollection.entity( self, expression_parser.to_mongobd_match(expr, *args, **kwargs)) elif isinstance(expr, pydocs.Fields): return pycollection.entity(self, pydocs.get_field_expr(expr)) else: raise Exception("invalid data type {0}".format(type(expr)))