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

make batch write "all or nothing" #400

Open
ktmud opened this issue Apr 30, 2014 · 1 comment
Open

make batch write "all or nothing" #400

ktmud opened this issue Apr 30, 2014 · 1 comment

Comments

@ktmud
Copy link
Contributor

ktmud commented Apr 30, 2014

Currently, the batch write mode is nothing but a grammar sugar, not really taking advantage of any adapter's batch write method.

To ensure errors are properly handled, one still need to write array iterations in the callback. If you want to retry creation with existing data, you'd have to remove successfully created objects (otherwise duplicates happen).

The currently behavior callback([, Error, ], [Object, null, Object]) breaks "all or nothing" principle for atomicity, make it difficult to trace Error (you have to print an array, or do iteration), and breaks API consistency (image you accidentally passed an Array to Model.create when you need it to be an object).

To avoid confusions and headaches, this mode should either be 1). removed, as it's not really "bulk inserting", 2). made atomic (at lease validate them all before starting to save()).

@1602
Copy link
Owner

1602 commented Apr 30, 2014

Problem in afterCreate. Imagine if you are sending emails after creation of some object. You can't "unsend" emails if you remove objects.

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

No branches or pull requests

2 participants