Ejemplo n.º 1
0
 def get(self, cls, obj_id):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     obj = self._cache.get((cls_info, obj_id))
     if obj is not None:
         return obj
     cursor = self._load(cls_info, collection.find,
                         {'_id': obj_id}, limit=2)
     if cursor.count():
         return self._build_doc(cls_info, cursor[0])
Ejemplo n.º 2
0
 def get(self, cls, obj_id):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     obj = self._cache.get((cls_info, obj_id))
     if obj is not None:
         return obj
     cursor = self._load(cls_info,
                         collection.find, {'_id': obj_id},
                         limit=2)
     if cursor.count():
         return self._build_doc(cls_info, cursor[0])
Ejemplo n.º 3
0
 def getCollection(self, cls):
     return get_cls_info(cls).get_collection(self.store)
Ejemplo n.º 4
0
 def find(self, cls, *args, **kwargs):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     cursor = self._load(cls_info, collection.find, *args, **kwargs)
     for item in cursor:
         yield self._build_doc(cls_info, item)
Ejemplo n.º 5
0
 def drop_collection(self, cls):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     collection.drop()
Ejemplo n.º 6
0
 def count(self, cls):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     return collection.find().count()
Ejemplo n.º 7
0
 def find_one_by(self, cls, **kwargs):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     item = self._load(cls_info, collection.find_one, **kwargs)
     if item is not None:
         return self._build_doc(cls_info, item)
Ejemplo n.º 8
0
 def find(self, cls, *args, **kwargs):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     cursor = self._load(cls_info, collection.find, *args, **kwargs)
     for item in cursor:
         yield self._build_doc(cls_info, item)
Ejemplo n.º 9
0
 def drop_collection(self, cls):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     collection.drop()
Ejemplo n.º 10
0
 def count(self, cls):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     return collection.find().count()
Ejemplo n.º 11
0
 def find_one_by(self, cls, **kwargs):
     cls_info = get_cls_info(cls)
     collection = cls_info.get_collection(self)
     item = self._load(cls_info, collection.find_one, **kwargs)
     if item is not None:
         return self._build_doc(cls_info, item)