repository.comments#

Module Contents#

Functions#

create_comment

Create a new comment in the database.

get_comments

Retrieve a list of comments for a specific picture from the database.

get_comment

Retrieve a specific comment by its ID from the database.

update_comment

Update a specific comment’s text content in the database.

delete_comment

Delete a specific comment from the database.

API#

async repository.comments.create_comment(body: src.schemas.comment.CommentSchema, picture_id: int, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Create a new comment in the database.

Parameters:
  • body (CommentSchema) – The schema representing the comment data.

  • picture_id (int) – The ID of the picture associated with the comment.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user creating the comment.

Returns:

The created comment.

Return type:

Comment

async repository.comments.get_comments(picture_id: int, offset: int, limit: int, db: sqlalchemy.ext.asyncio.AsyncSession)#

Retrieve a list of comments for a specific picture from the database.

Parameters:
  • picture_id (int) – The ID of the picture for which comments are retrieved.

  • offset (int) – The offset for pagination.

  • limit (int) – The limit for the number of comments to retrieve.

  • db (AsyncSession) – The asynchronous database session.

Returns:

A list of comments.

Return type:

List[Comment]

async repository.comments.get_comment(comment_id: int, db: sqlalchemy.ext.asyncio.AsyncSession)#

Retrieve a specific comment by its ID from the database.

Parameters:
  • comment_id (int) – The ID of the comment to retrieve.

  • db (AsyncSession) – The asynchronous database session.

Returns:

The retrieved comment or None if not found.

Return type:

Optional[Comment]

async repository.comments.update_comment(comment_id: int, body: src.schemas.comment.CommentSchema, db: sqlalchemy.ext.asyncio.AsyncSession, user: src.entity.models.User)#

Update a specific comment’s text content in the database.

Parameters:
  • comment_id (int) – The ID of the comment to update.

  • body (CommentSchema) – The schema representing the updated comment data.

  • db (AsyncSession) – The asynchronous database session.

  • user (User) – The user updating the comment.

Returns:

The updated comment or None if not found.

Return type:

Optional[Comment]

async repository.comments.delete_comment(comment_id: int, db: sqlalchemy.ext.asyncio.AsyncSession)#

Delete a specific comment from the database.

Parameters:
  • comment_id (int) – The ID of the comment to delete.

  • db (AsyncSession) – The asynchronous database session.

Returns:

The deleted comment or None if not found.

Return type:

Optional[Comment]