When interacting with subcollections inside a transaction, the subcollections should also be TransactionRepositories to ensure consistency and proper transaction handling. Currently, subcollections do not automatically switch to TransactionRepositories within transactions.
Steps to Reproduce
Start a transaction and interact with a subcollection.
Observe that the subcollection is not treated as a TransactionRepository.
Expected Behavior
Subcollections should automatically switch to TransactionRepositories when inside a transaction.
Actual Behavior
Subcollections remain as regular repositories, not switching to TransactionRepositories within transactions.
Acceptance Criteria
Change the type of ISubCollection<Entity> to ITransactionRepository<Entity> when interacting with subcollections inside a transaction.
Ensure that all subcollection interactions within a transaction use the TransactionRepository.
Add unit tests to validate the behavior of subcollections within transactions.
Additional Context
June 10, 2022: Initial issue raised about the need for subcollections to use TransactionRepositories inside transactions.
June 17, 2022: Agreement on the need for the change and a request for a pull request.
Proposed API Changes
Update ISubCollection Type:
Change the type of ISubCollection<Entity> to ITransactionRepository<Entity> when inside a transaction.
interface ISubCollection<Entity> {
// Existing methods...
}
interface ITransactionRepository<Entity> extends ISubCollection<Entity> {
// Additional methods specific to transactions...
}
Modify Repository Initialization:
Ensure that subcollections are initialized as TransactionRepositories when inside a transaction.
iamgbayer's Issue (Mar 16, 2022): Queries about automatically querying subcollections and could indirectly relate to handling subcollections in transactions.
Description
When interacting with subcollections inside a transaction, the subcollections should also be
TransactionRepositories
to ensure consistency and proper transaction handling. Currently, subcollections do not automatically switch toTransactionRepositories
within transactions.Steps to Reproduce
TransactionRepository
.Expected Behavior
Subcollections should automatically switch to
TransactionRepositories
when inside a transaction.Actual Behavior
Subcollections remain as regular repositories, not switching to
TransactionRepositories
within transactions.Acceptance Criteria
ISubCollection<Entity>
toITransactionRepository<Entity>
when interacting with subcollections inside a transaction.TransactionRepository
.Additional Context
TransactionRepositories
inside transactions.Proposed API Changes
Update ISubCollection Type:
ISubCollection<Entity>
toITransactionRepository<Entity>
when inside a transaction.Modify Repository Initialization:
TransactionRepositories
when inside a transaction.Unit Tests:
TransactionRepositories
within transactions.Example Implementation
Original Issue