How to use the fireo.utils.utils.get_id 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 / get_query.py View on Github external
def __init__(self, model_cls, key):
        super().__init__(model_cls)
        super().set_collection_path(key=key)
        self.model = model_cls()
        # set parent to this model if any
        self.model.parent = utils.get_parent_doc(key)
        # Attach key to this model for updating this model
        # Purpose of attaching this key is user can update
        # this model after getting it
        #
        # For example:
        #   u = User.collection.get(user_key)
        #   u.name = "Updated Name"
        #   u.update()
        self.model._update_doc = key
        self.id = utils.get_id(key)
github octabytes / FireO / src / fireo / queries / update_query.py View on Github external
def _doc_ref(self):
        """create document ref from firestore"""
        return self.get_ref().document(utils.get_id(self.model.key))
github octabytes / FireO / src / fireo / queries / filter_query.py View on Github external
u = User.collection.get(user_key)
          u.name = "Updated Name"
          u.update()

        Parameters
        ----------
        model:
            Current model where update key need to attach

        Returns
        -------
        update_doc_key:
            Doc key for updating document
        """
        if self.parent:
            update_doc_key = self.parent + '/' + model.collection_name + '/' + utils.get_id(model.key)
        else:
            update_doc_key = model.key
        return update_doc_key
github octabytes / FireO / src / fireo / models / model.py View on Github external
def to_dict(self):
        """Convert model into dict"""
        model_dict = self._get_fields()
        id = 'id'
        if self._meta.id is not None:
            id, _ = self._meta.id
        model_dict[id] = utils.get_id(self.key)
        model_dict['key'] = self.key
        return model_dict