Skip to content

Conversation

@vwkd
Copy link
Contributor

@vwkd vwkd commented May 22, 2025

This attempts to implement batching for the mutate method of an atomic transaction, which currently despite the docs saying so wasn't implemented yet.

This passes the mutation arguments to mutate through to the individual mutation methods set, delete, sum, max, min, effectively making mutate a shorthand for chained calls to the individual mutation methods. This avoids having to add more complex batching logic in commit specifically for mutate, since commit already handles batching for the individual mutation methods.

Not sure if this is the right approach and if this maintains consistency of the transaction.

Fixes #17.

case "min":
this.min(mutation.key, mutation.value.value);
break;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a default statement throwing invalid mutations at runtime instead of relying on TypeScript types in this exhaustive switch statement?

@kitsonk
Copy link
Owner

kitsonk commented May 24, 2025

Thanks for the PR. I am going to think about it, because it actually may make more sense to "unwrap" the individual methods and call mutate on the underlying store fore everything.

@kitsonk
Copy link
Owner

kitsonk commented May 24, 2025

Again thanks, the implementation was there, it was just putting it into the commit queue, but it was processing it as a single transaction and not batching it up like I thought. So I refactored the whole thing in 4d02534. Thanks for the test case though and I added you as co-author on the ultimate fix.

@kitsonk kitsonk closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Total mutation size too large

2 participants