1602 / 1602/jugglingdb

make batch write "all or nothing"

Offen
#400 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
2k
Forks
238
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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()`).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Look at the batch write implementation in the codebase, likely in the ORM's core or adapter layer. Examine how Model.create handles arrays and the current error handling. The goal is to modify the batch operation to be atomic, either by validating all records before saving or by using the adapter's native batch methods. Testing will involve creating and running tests for batch writes with error scenarios.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
databases, javascript, node.js
Bereich
backend, databases
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.