# Path: dockit/backends/queryset.py
# class QuerySet(object):
#     '''
#     Acts as a caching layer around an implemented `BaseDocumentQuery`
#     TODO: implement actual caching
#     '''
#     def __init__(self, query):
#         self.query = query
#     
#     @property
#     def document(self):
#         return self.query.document
#     
#     def __len__(self):
#         #TODO cache
#         return self.query.__len__()
#     
#     def count(self):
#         return self.__len__()
#     
#     def delete(self):
#         return self.query.delete()
#     
#     def values(self, *limit_to, **kwargs):
#         #TODO cache
#         return self.query.values(*limit_to, **kwargs)
#     
#     def get(self, **kwargs):
#         #TODO cache
#         return self.query.get(**kwargs)
#     
#     def exists(self):
#         return self.query.exists()
#     
#     def __getitem__(self, val):
#         #TODO cache
#         return self.query.__getitem__(val)
#     
#     def __nonzero__(self):
#         #TODO cache
#         return self.query.__nonzero__()
#     
#     def __iter__(self):
#         return iter(self.query)


import copy
import hashlib
import json
from dockit.backends.queryset import QuerySet
            from dockit.schema import Document
            from django.db.models import Model
        from dockit.schema.loading import register_indexes
        from dockit.backends import get_index_router


class QueryFilterOperation(object):
    def __init__(self, key, operation, value):
        self.key = key
        self.operation = operation
        if value is not None:
            if isinstance(value, Model):
                value = value.pk
            if isinstance(value, Document):
                value = value.pk
        self.value = value
    
    def __hash__(self):
        assert self.key is not None
        assert self.operation is not None

# Path: dockit/backends/queryset.py
# class QuerySet(object):
#     '''
#     Acts as a caching layer around an implemented `BaseDocumentQuery`
#     TODO: implement actual caching
#     '''
#     def __init__(self, query):
#         self.query = query
#     
#     @property
#     def document(self):
#         return self.query.document
#     
#     def __len__(self):
#         #TODO cache
#         return self.query.__len__()
#     
#     def count(self):
#         return self.__len__()
#     
#     def delete(self):
#         return self.query.delete()
#     
#     def values(self, *limit_to, **kwargs):
#         #TODO cache
#         return self.query.values(*limit_to, **kwargs)
#     
#     def get(self, **kwargs):
#         #TODO cache
#         return self.query.get(**kwargs)
#     
#     def exists(self):
#         return self.query.exists()
#     
#     def __getitem__(self, val):
#         #TODO cache
#         return self.query.__getitem__(val)
#     
#     def __nonzero__(self):
#         #TODO cache
#         return self.query.__nonzero__()
#     
#     def __iter__(self):
#         return iter(self.query)


# Path: dockit/backends/queryindex.py
import copy
import hashlib
import json
from dockit.backends.queryset import QuerySet
            from dockit.schema import Document
            from django.db.models import Model
        from dockit.schema.loading import register_indexes
        from dockit.backends import get_index_router



class QueryFilterOperation(object):
    def __init__(self, key, operation, value):
        self.key = key
        self.operation = operation
        if value is not None:
            if isinstance(value, Model):
                value = value.pk
            if isinstance(value, Document):
                value = value.pk
        self.value = value
    
    def __hash__(self):
        assert self.key is not None
        assert self.operation is not None

        if self.value is None: