diffsync.store.local
LocalStore module.
- class diffsync.store.local.LocalStore(*args: Any, **kwargs: Any)
Bases:
BaseStore
LocalStore class.
- __init__(*args: Any, **kwargs: Any) None
Init method for LocalStore.
- add(*, obj: DiffSyncModel) None
Add a DiffSyncModel object to the store.
- Parameters:
obj – Object to store
- Raises:
ObjectAlreadyExists – if a different object with the same uid is already present.
- count(*, model: str | DiffSyncModel | Type[DiffSyncModel] | None = None) int
Returns the number of elements of a specific model, or all elements in the store if unspecified.
- get(*, model: str | DiffSyncModel | Type[DiffSyncModel], identifier: str | Dict) DiffSyncModel
Get one object from the data store based on its unique id.
- Parameters:
model – DiffSyncModel class or instance, or modelname string, that defines the type of the object to retrieve
identifier – Unique ID of the object to retrieve, or dict of unique identifier keys/values
- Raises:
ValueError – if obj is a str and identifier is a dict (can’t convert dict into a uid str without a model class)
ObjectNotFound – if the requested object is not present
- get_all(*, model: str | DiffSyncModel | Type[DiffSyncModel]) List[DiffSyncModel]
Get all objects of a given type.
- Parameters:
model – DiffSyncModel class or instance, or modelname string, that defines the type of the objects to retrieve
- Returns:
List of Object
- get_all_model_names() Set[str]
Get all the model names stored.
- Returns:
Set of all the model names.
- get_by_uids(*, uids: List[str], model: str | DiffSyncModel | Type[DiffSyncModel]) List[DiffSyncModel]
Get multiple objects from the store by their unique IDs/Keys and type.
- Parameters:
uids – List of unique id / key identifying object in the database.
model – DiffSyncModel class or instance, or modelname string, that defines the type of the objects to retrieve
- Raises:
ObjectNotFound – if any of the requested UIDs are not found in the store
- remove_item(modelname: str, uid: str) None
Remove one item from store.
- update(*, obj: DiffSyncModel) None
Update a DiffSyncModel object to the store.
- Parameters:
obj – Object to update