Base

Module that represents the Base repository.

class BaseRepository(manager, model)[source]

Class that implements the base repository methods.

Default constructor for base repository.

Parameters:
  • manager (DatabaseManager) – The database manager instance.

  • model (Any) – The SQLAlchemy model to use in the repository.

delete(identifier)[source]

Default method to remove entries from the database.

Return type:

None

Note

This method will actually call update internally to update the deleted_at field in the table.

Parameters:

identifier (Union[UUID, str]) – The unique identifier to query in the database.

delete_by_chat_id(chat_id)[source]

Default method to remove entries from the database.

Return type:

None

Note

This method will actually call update internally to update the deleted_at field in the table.

Parameters:

chat_id (Union[UUID, str]) – The unique identifier to query in the database.

insert(values)[source]

Default method to make insertions in the database.

Return type:

Row

Parameters:

values (dict[str, Any]) – The values to insert in the database

Returns:

A row represented as a tuple with the id inserted.

Return type:

Row

select()[source]

Default method to retrieve information from the database.

Return type:

Any

Returns:

Information retrieved from the database

Return type:

Any

select_all_by_id(identifier)[source]

Default method to select all entries by filtering using an identifier.

Return type:

Any

Parameters:

identifier (Union[UUID, str]) – The unique identifier to query in the database.

Returns:

Information retrieved from the database.

Return type:

Any

select_all_by_user_id(user_id)[source]

Default method to select all entries by filtering using an identifier.

Return type:

Any

Parameters:

user_id (Union[UUID, str]) – The unique identifier to query in the database.

Returns:

Information retrieved from the database.

Return type:

Any

select_by_id(identifier)[source]

Default method to select by filtering using an identifier.

Return type:

Any

Parameters:

identifier (Union[UUID, str]) – The unique identifier to query in the database.

Returns:

The information retrieved from the database.

Return type:

Any

select_by_name(user_id, name)[source]

Default method to select rows by using a name.

Return type:

Any

Parameters:
  • user_id (str) – The user’s identifier.

  • name (str) – The name to query in the database.

Returns:

The information retrieved from the database.

Return type:

Any

select_first()[source]

Default method to get first information from the database.

Return type:

Any

Returns:

The first information retrieved from the database

Return type:

Any

update(values, identifier)[source]

Default method to update values in the database.

Return type:

None

Parameters:
  • values (dict[str, Any]) – The values to update in the database.

  • identifier (Union[UUID, str]) – The unique identifier to query in the database.