diffsync.store.local

LocalStore module.

class diffsync.store.local.LocalStore(*args, **kwargs)

Bases: diffsync.store.BaseStore

LocalStore class.

__init__(*args, **kwargs) None

Init method for LocalStore.

add(*, obj: DiffSyncModel)

Add a DiffSyncModel object to the store.

Parameters

obj (DiffSyncModel) – Object to store

Raises

ObjectAlreadyExists – if a different object with the same uid is already present.

count(*, model: Optional[Union[str, DiffSyncModel, Type[DiffSyncModel]]] = None) int

Returns the number of elements of a specific model, or all elements in the store if unspecified.

get(*, model: Union[str, DiffSyncModel, Type[DiffSyncModel]], identifier: Union[str, Mapping]) 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: Union[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

Return type

List[DiffSyncModel]

get_all_model_names() Set[str]

Get all the model names stored.

Returns

Set of all the model names.

Return type

Set[str]

get_by_uids(*, uids: List[str], model: Union[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)

Remove one item from store.

update(*, obj: DiffSyncModel)

Update a DiffSyncModel object to the store.

Parameters

obj (DiffSyncModel) – Object to update