@classmethod
def filter(cls, key, value, operator):
    """
        Adds a filter to the current query
        """
    column = getattr(cls, key)
    if isinstance(value, list):
        return cls.q.where(column.in_(value))
    if operator == '!':
        return cls.q.where(column != value)
    elif operator == '>':
        return cls.q.where(column > value)
    elif operator == '<':
        return cls.q.where(column < value)
    elif operator == '~':
        return cls.q.where(column.startswith(value))
    return cls.q.where(column == value)
