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