How to use the fireo.database.db.conn 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 / fields / fields.py View on Github external
def db_value(self, model):
        # check reference model and passing model is same
        if not issubclass(model.__class__, self.model_ref):
            raise errors.ReferenceTypeError(f'Invalid reference type. Field "{self.name}" required value type '
                                            f'{self.model_ref.__name__}, but got {model.__class__.__name__}')
        # Get document reference from firestore
        return firestore.DocumentReference(*utils.ref_path(model.key), client=db.conn)
github octabytes / FireO / src / fireo / queries / base_query.py View on Github external
def get_ref(self):
        """Provide firestore ref for model collection"""

        #  Validate the key
        self.validate_key()

        if self.group_collection:
            return db.conn.collection_group(self.collection_path)

        return db.conn.collection(self.collection_path)
github octabytes / FireO / src / fireo / fields / reference_field.py View on Github external
def db_value(self, model):
        # if no model is provided then return None
        if model is None:
            return None
        # check reference model and passing model is same
        if not issubclass(model.__class__, self.model_ref):
            raise errors.ReferenceTypeError(f'Invalid reference type. Field "{self.name}" required value type '
                                            f'"{self.model_ref.__name__}", but got "{model.__class__.__name__}"')
        # Get document reference from firestore
        return firestore.DocumentReference(*utils.ref_path(model.key), client=db.conn)
github octabytes / FireO / src / fireo / queries / base_query.py View on Github external
def get_ref(self):
        """Provide firestore ref for model collection"""

        #  Validate the key
        self.validate_key()

        if self.group_collection:
            return db.conn.collection_group(self.collection_path)

        return db.conn.collection(self.collection_path)
github octabytes / FireO / src / fireo / __init__.py View on Github external
def transaction(**kwargs):
    return db.conn.transaction(**kwargs)