Currently all the functions of onyx take in a *badger.Txn as their final argument which lets the user pass in a transaction under which the graph operation should be executed. However, currently there is no way for users of Onyx to actually create a new *badger.Txn without calling graph.DB.NewTransaction(), which requires the DB field of the Graph struct to be publicly exposed, which is not ideal.
Create a function NewTransaction on the Graph struct which returns a *badger.Txn for the users to use. Note that NewTransaction should take in a boolean which tells it if a read-only txn or a read-write txn.
Remember to create a unit test for this function!
psst, remember to update the usage guide in the README too 👀
Currently all the functions of onyx take in a
*badger.Txnas their final argument which lets the user pass in a transaction under which the graph operation should be executed. However, currently there is no way for users of Onyx to actually create a new*badger.Txnwithout callinggraph.DB.NewTransaction(), which requires theDBfield of theGraphstruct to be publicly exposed, which is not ideal.Create a function
NewTransactionon theGraphstruct which returns a*badger.Txnfor the users to use. Note thatNewTransactionshould take in a boolean which tells it if a read-only txn or a read-write txn.Remember to create a unit test for this function!
psst, remember to update the usage guide in the README too 👀