lomocoin/PHP-Mongo-Transaction

Refactor "Transaction" class and "Database Design"

zzdjk6 opened this issue · 1 comments

Currently, we make database change inside "Transaction" class directly, maybe it is better to use this class as an "Manager", and make the "Transaction Log" as a separated class which adopt Persistable interface.

Furthermore, we should add time field for "Transaction Log" which is useful when future scheduled task (e.g cron) to check if there is an unexpected behavior for each transaction.


Another problem here is: we now have "state change log collection" and "transaction collection" in database, which I think might not be the best design.

Maybe we only need 1 collection: the "transaction collection", with 2 Persistable class "Transaction Log" and "State Change Log", while:

  • "Transaction Log" contains id, timestamp, array of operation logs, array of rollback logs
  • "State Change Log" behave just like the current one