Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multi book commit #113

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

ChyzhykTech
Copy link
Collaborator

This PR introduces a new helper function commit designed to handle the transactional commit of multiple entries within a MongoDB session. Using the mongoTransaction helper, ensures atomicity and data integrity during the commit process.

Expected syntax to use:

var entry1 = book1.debit().credit();
var entry2 = book2.debit().credit();
const [j1, j2] = await medici.commit(entry1, entry2);

Serhii Chyzhyk and others added 4 commits February 9, 2024 23:48
New helper function `commit` to handle the simultaneous transaction commit for multiple entries
This commit introduces a new function commit designed to handle the transactional commit of multiple entries within a MongoDB session. Using the mongoTransaction utility, it ensures atomicity and data integrity during the commit process.
@ChyzhykTech ChyzhykTech self-assigned this Feb 10, 2024
@ChyzhykTech
Copy link
Collaborator Author

Could you please provide your expert opinion, @koresar, regarding the new function and share your thoughts?

I want to note that the new function requires the creation of corresponding unit tests. However, before proceeding, I would still like to receive feedback regarding the changes.

@ChyzhykTech ChyzhykTech removed their assignment Feb 11, 2024
@hmvs hmvs self-requested a review February 12, 2024 01:00
@koresar
Copy link
Collaborator

koresar commented Feb 12, 2024

I would avoid involving sessions for the single collection document insertions.

…allow committing empty entries.

This function commits a list of entries to the database using a MongoDB (mongoTransaction helper function) transaction if there are multiple entries provided. It ensures atomicity for multiple commits. However, it does not use a transaction for single commits and prohibits committing empty entries.
@ChyzhykTech
Copy link
Collaborator Author

I would avoid involving sessions for the single collection document insertions.

Dear @koresar,
Following your suggestion, we won't use a session for a single commit.
Additionally, I've implemented a check to disallow committing zero entries (MediciError is thrown).

Could you please review it again?

Thank you.

@koresar
Copy link
Collaborator

koresar commented Feb 14, 2024

We need to talk. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants