-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: support bulk transactions #10
Conversation
size-limit report 📦
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 3 4 +1
Lines 641 918 +277
Branches 37 62 +25
==========================================
+ Hits 641 918 +277 ☔ View full report in Codecov by Sentry. |
bulk()
method and createBulkTransaction()
helperThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work Angelo!
*/ | ||
type BulkTransactionAPIResponse = { | ||
details: { | ||
customTypes: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ What does the API return if too many slices are sent? Are they going to end up in this details.customTypes
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong, but I didn't see anything about slices in Slice Machine's /bulk
error handling; SM only validates that the customTypes
object is present.
I think this is because limitation errors should only happen if too many documents need to be deleted. Documents are only deleted if custom types are deleted, which does not concern slices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see. Thanks ^^
….prototype.fromDiff()`
@bapmrl Thanks for the review! I'm going to merge the PR to move forward with the GitHub integration, but feel free to reply to any of my replies and I can still make changes to the implementation. |
Types of changes
Description
This PR adds support for bulk transactions, which are a way to process multiple operations (insert, update, delete) in one request.
Internally, it makes use of the Types API's
/bulk
endpoint.The following APIs are introduced:
client.bulk()
method to perform multiple operations at once.createBulkTransaction()
helper to build a set of bulk operations.Using
client.bulk()
looks like this:A bulk transaction can be created from a before and after set of models using the
fromDiff()
method:createBulkTransaction()
is recommended when usingclient.bulk()
, but not required:Refer to the TypeScript types to learn how to use
bulk()
directly.Checklist: