bovid.aggregates.molecule.repo module¶
- class bovid.aggregates.molecule.repo.MoleculeRepoProtocol¶
Bases:
RepoProtocol[MoleculeAgg],Protocol
- class bovid.aggregates.molecule.repo.MoleculeRepoFake¶
Bases:
MoleculeRepoProtocol,RepoFake[MoleculeAgg]- __init__(storage)¶
- Parameters:
storage (dict[int, MoleculeAgg])
- class bovid.aggregates.molecule.repo.MoleculeRepo¶
Bases:
MoleculeRepoProtocol- __init__(sql_conn, obj_driver)¶
- Parameters:
sql_conn (Connection)
obj_driver (ObjectStoreDriver)
- Return type:
None
- sql_conn: Connection¶
- obj_driver: ObjectStoreDriver¶
- commit()¶
- Return type:
None
- rollback()¶
- Return type:
None
- close()¶
- Return type:
None
- create(molecule)¶
Create a new entity.
If an entity exists that matches this entity no new entity is created and the existing ID is returned. There is a return value that reports if this was the case.
- Parameters:
agg – The domain model object to add to the repository.
molecule (MoleculeAgg)
- Returns:
The ID of model in storage (can be new or old ID) already_exists: True if entity already existed.
- Return type:
id
See also
If you want to in-place replace an existing entity but keep the same ID use the replace method if available.
If you want to update some fields of an entity see the update method.
- list()¶
List all aggregates.
- Returns:
list of tuples of (aggregate_id, aggregate)
- Return type:
aggregates
- retrieve(mol_id)¶
Get an entity by reference.
- Parameters:
id – The ID of model to retrieve.
mol_id (int)
- Returns:
The ID of model retrieved. agg: The domain model object to add to the repository.
- Return type:
id
- replace(mol_id, mol)¶
Get an entity by reference.
- Parameters:
id – The ID of model to retrieve.
agg – The domain model object to add to the repository.
mol_id (int)
mol (MoleculeAgg)
- Returns:
Reports if replacement was successful.
- Return type:
success
See also
See the update method if just want to update some specific parts of the model with a patch.
- update(mol_id, patch)¶
Partial update of an aggregate.
- Parameters:
- Returns:
If Aggregate exists the patched version, otherwise None. success: Whether the actual write operation of the patched Aggregate succeeded.
- Return type:
maybe_model
See also
See the replace method if you want to replace the entire model and not just a diff.
- class bovid.aggregates.molecule.repo.MoleculeUnitOfWork¶
Bases:
UnitOfWorkProtocol[BovidServerState,MoleculeAgg]- repo: MoleculeRepoFake | MoleculeRepo¶
- commit()¶
- Return type:
None
- __init__(repo)¶
Method generated by attrs for class MoleculeUnitOfWork.
- Parameters:
repo (MoleculeRepoFake | MoleculeRepo)
- Return type:
None
- rollback()¶
- Return type:
None