Allison-E / pg-age

Apache License 2.0
8 stars 2 forks source link

Supporting Transactions #5

Open bozau opened 2 weeks ago

bozau commented 2 weeks 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 1 week 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.