How to use the fireo.queries.query_wrapper.ModelWrapper function in fireo

To help you get started, we’ve selected a few fireo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github octabytes / FireO / src / fireo / queries / update_query.py View on Github external
def exec(self, transaction_or_batch=None):
        """return modified instance of model"""
        if transaction_or_batch:
            return self._raw_exec(transaction_or_batch)
        return query_wrapper.ModelWrapper.from_query_result(self.model, self._raw_exec())
github octabytes / FireO / src / fireo / queries / query_iterator.py View on Github external
def __next__(self):
        try:
            doc = next(self.docs, None)
            if doc:
                # Suppose this is the last doc
                self.last_doc = doc
                m = query_wrapper.ModelWrapper.from_query_result(self.model_cls(), doc)
                m._update_doc = self.query._update_doc_key(m)
                # Suppose this is last doc
                self.last_doc_key = m.key
                return m
            self.fetch_end = True
            # Save last doc key in cursor
            self.query.cursor_dict['last_doc_key'] = self.last_doc_key
            raise StopIteration
        except Exception:
            raise StopIteration
github octabytes / FireO / src / fireo / queries / create_query.py View on Github external
def exec(self):
        """return modified or new instance of model"""
        return query_wrapper.ModelWrapper.from_query_result(self.model, self._raw_exec())
github octabytes / FireO / src / fireo / queries / get_query.py View on Github external
def exec(self, transaction=None):
        """Wrap the query result into model instance"""
        return query_wrapper.ModelWrapper.from_query_result(self.model, self._raw_exec(transaction))
github octabytes / FireO / src / fireo / queries / filter_query.py View on Github external
def get(self):
        """Get the first matching document from firestore

        Get first matching document and convert it into model and return it
        This is same as `fetch(limit=1)` the only difference is `get()` method
        return **model instance** and the `fetch()` method return the **generator**
        """
        self.n_limit = 1
        doc = next(self.query().stream(self.query_transaction), None)
        if doc:
            m = query_wrapper.ModelWrapper.from_query_result(self.model, doc)
            m._update_doc = self._update_doc_key(m)
            return m
        return None
github octabytes / FireO / src / fireo / queries / create_query.py View on Github external
def exec(self, transaction_or_batch=None):
        """return modified or new instance of model"""
        if transaction_or_batch:
            return self._raw_exec(transaction_or_batch)
        return query_wrapper.ModelWrapper.from_query_result(self.model, self._raw_exec())