Repository base
FKDict = dict[str, int] | None
module-attribute
RepositoryBase
Bases: Generic[DatabaseSchemaType, UniqueIDType], ABC
Implements generic behaviour for all repositories.
UID
instance-attribute
read_only = False
class-attribute
schema_class = None
class-attribute
create(schema, foreign_keys=None)
async
Create a new entry in the database.
Top level schema must be new, but sub-schemas can already exist. In the case that sub-schemas already exist, they should already have the persistent IDs set (e.g. after loading).
get(unique_id, *, include_deleted=False, fully_load=False, **kwargs)
async
Load a schema from the database by name and type.
| PARAMETER | DESCRIPTION |
|---|---|
unique_id
|
The unique id of the schema to load
TYPE:
|
include_deleted
|
Whether to include deleted schemas in the search
TYPE:
|
fully_load
|
Whether to fully load the schema (e.g. load all sub-schemas). For some repositories, this may have no effect.
TYPE:
|
kwargs
|
Additional arguments to pass to _get method (Note: For easier extension, subclasses should use explicit keywords if they use additional arguments)
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
DatabaseSchemaType
|
The loaded schema |
| RAISES | DESCRIPTION |
|---|---|
NotFoundError
|
If the schema does not exist |
DeletedError(NotFoundError)
|
If schema is found but marked deleted |
mark_deleted(unique_id)
async
Mark a schema as deleted in the database.
This should act as effectively deleting, but without actually removing from the database. Just setting a flag instead. This should prevent most operations from returning the schema.
update(schema, foreign_keys=None, include_deleted=False, fully_load=False)
async
Update an existing schema in the database.
(actually creates a new entry with an incremented version number)
SQLRepositoryMixin
Bases: Generic[UniqueIDType]