harp_apps.storage.models.base

Inheritance diagram of harp_apps.storage.models.base

class Base[source]

Bases: AsyncAttrs, DeclarativeBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Parameters:
Return type:

None

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

See also

orm_declarative_metadata

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class Repository[source]

Bases: Generic[TRow]

__init__(session_factory, /)[source]
count()[source]
async create(values, /, *, session)[source]
Parameters:

values (dict)

delete()[source]
async find_one(values, /, session, **select_kwargs)[source]
Parameters:

values (dict)

Return type:

TRow

async find_one_by_id(id, /, session=None, **select_kwargs)[source]
Parameters:

id (str)

Return type:

TRow

async find_or_create_one(values, /, session, defaults=None, **select_kwargs)[source]
Parameters:

values (dict)

Return type:

TRow

select()[source]
update()[source]
Type: TRow = None
with_session(f)[source]

Decorates a method to ensure it is called with a sql alchemy session, if it is not, then create one to wrap the call.

Parameters:

f

Returns: