Skip to content

What if a repository method must be called within the same transaction? #5

Description

@frederikhors

Hi dear and amazing @AngusGMorrison,

a doubt:

In the repository function create_author I need to call another repository method (example: check_if_author_name_is_already_taken(req.name())) and I need to call it within the same transaction I'm creating on line 50.

How to?

Plus the same method can be called not in a transaction too!

Should I have a new argument on the repository method?

An argument to indicate both a db connection or a db transaction?

Something like:

impl BlogRepository for Sqlite {
    async fn create_author(&self, req: &CreateAuthorRequest) -> Result<Author, CreateAuthorError> {}

    async fn check_if_author_name_is_already_taken(&self, db_conn_or_tx: ??? what type here ???, name: &str) -> Result<bool, String> {}
}

I'm asking for you help too, @TmLev.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions