Allison-E / pg-age

Apache License 2.0
11 stars 5 forks source link

Supporting Transactions #5

Open bozau opened 5 months ago

bozau commented 5 months ago

G'day, first off just wanted to thank you for creating the project, it's been really nice to have.

I was wondering about the addition of support for transactions?

Would it be just adding functions within the AgeClient class?

Cheers.

Boz.

Allison-E commented 5 months ago

Hello, @bozau. Thank you for your kind words.

Yes. Transaction support could easily be added as functions, but I won't want them in the AgeClient class.

For a good design, I suggest having an object in AgeClient, AgeClient.Database, which will refer to the PostgreSQL database and contain all necessary database-related actions like beginning and committing transactions. This will prevent AgeClient from becoming bloated.

If the proposed design is implemented, beginning transactions will be a call to the function AgeClient.Database.BeginTransactionAsync(). Subsequently, some database-related actions currently in the AgeClient will also be moved to AgeClient.Database.