Пример #1
0
 def _query_items_simple(self, firebase_query):
     snapshots = self._stream_ref(firebase_query)
     results = []
     for snapshot in snapshots:
         wrapper = ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot))
         results.append(GenericObject.from_row(self, wrapper))
     return results
Пример #2
0
 def _query_items_simple(self, firebase_query):
     snapshots = firebase_query.get()
     results = []
     for snapshot in snapshots:
         wrapper = ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot))
         results.append(GenericObject.from_row(self, wrapper))
     return results
Пример #3
0
 def _get_refs_from(self, key, type_name, field_name):
     type_ref = self.db.collection(type_name)
     query_ref = type_ref.where(field_name, u'==', key)
     snapshots = self._stream_ref(query_ref)
     rows = [ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot)) for snapshot in snapshots]
     objs = [GenericObject._from_doc(self, row.key, row.rev, row.value) for row in rows]
     return objs
Пример #4
0
 def _get_refs_from(self, key, type_name, field_name):
     type_ref = self.db.collection(type_name)
     query_ref = type_ref.where(field_name, u'==', key)
     snapshots = query_ref.get()
     rows = [ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot)) for snapshot in snapshots]
     objs = [GenericObject._from_doc(self, row.key, row.rev, row.value) for row in rows]
     return objs
Пример #5
0
    def get_unique_instance(self, namespace, type_name, field_name, value):
        unique_type_name = "%s__%s" % (type_name, field_name)
        unique_doc_ref = self.db.collection(unique_type_name).document(value)
        try:
            doc = unique_doc_ref.get()
            as_dict = doc.to_dict()
            wrapper = self._get(as_dict["owner"], as_dict["type_name"])
            return GenericObject._from_doc(self, wrapper.key, wrapper.rev, wrapper.value)

        except NotFound:
            return None
Пример #6
0
    def query_items_iterator(self,
                             firebase_query,
                             batch_size,
                             order_by=u'_id'):

        for snapshot in self.query_snapshots_iterator(firebase_query,
                                                      batch_size=batch_size,
                                                      order_by=order_by):
            wrapper = ResultWrapper.from_couchdb_json(
                self.value_from_snapshot(snapshot))
            obj = GenericObject.from_row(self, wrapper)
            yield obj
Пример #7
0
 def get_single_type(self, namespace, type_name):
     type_ref = self.db.collection(type_name)
     snapshots = self._stream_ref(type_ref)
     rows = [
         ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot))
         for snapshot in snapshots
     ]
     objs = [
         GenericObject._from_doc(self, row.key, row.rev, row.value)
         for row in rows
     ]
     return objs
Пример #8
0
    def get_unique_instance(self, namespace, type_name, field_name, value):
        unique_type_name = "%s__%s" % (type_name, field_name)
        unique_doc_ref = self.db.collection(unique_type_name).document(value)

        doc = self._get_ref(unique_doc_ref)

        if doc.exists:
            as_dict = doc.to_dict()
            wrapper = self._get(as_dict["owner"], as_dict["type_name"])
            return GenericObject._from_doc(self, wrapper.key, wrapper.rev, wrapper.value)
        else:
            return None
Пример #9
0
 def changes(self,
             since=None,
             channels=None,
             limit=None,
             feed=None,
             timeout=None,
             filter=None):
     return GenericObject.changes(self,
                                  since=since,
                                  channels=channels,
                                  limit=limit,
                                  feed=feed,
                                  timeout=timeout,
                                  filter=filter)
Пример #10
0
 def delete_key(self, key):
     return GenericObject.delete_key(self, key)
Пример #11
0
 def query_view(self, view_name, **kwargs):
     return GenericObject.view(self, view_name, **kwargs)
Пример #12
0
 def changes(self, since=None, channels=None, limit=None, feed=None, timeout=None, filter=None):
     return GenericObject.changes(self, since=since, channels=channels, limit=limit, feed=feed, timeout=timeout, filter=filter)
Пример #13
0
 def get(self, key, class_name=None):
     return GenericObject.get(self, key, class_name=class_name)
Пример #14
0
 def query_view(self, view_name, **kwargs):
     return GenericObject.view(self, view_name, **kwargs)
Пример #15
0
 def delete_key(self, key):
     return GenericObject.delete_key(self, key)
Пример #16
0
 def get(self, key, class_name=None):
     return GenericObject.get(self, key, class_name=class_name)
Пример #17
0
 def get_single_type(self, namespace, type_name):
     type_ref = self.db.collection(type_name)
     docs = type_ref.get()
     rows = [ResultWrapper.from_couchdb_json(doc.to_dict()) for doc in docs]
     objs = [GenericObject._from_doc(self, row.key, row.rev, row.value) for row in rows]
     return objs
Пример #18
0
    def query_items_iterator(self, firebase_query, batch_size, order_by=u'_id'):

        for snapshot in self.query_snapshots_iterator(firebase_query, batch_size=batch_size, order_by=order_by):
            wrapper = ResultWrapper.from_couchdb_json(self.value_from_snapshot(snapshot))
            obj = GenericObject.from_row(self, wrapper)
            yield obj