datastax / astra-db-java

Java Client for DataStax Astra DB and the Data API
https://datastaxdevs.github.io/astra-db-java/latest/
Apache License 2.0
11 stars 3 forks source link

Implement support for `returnDocumentPositions` for `insertMany` #15

Closed clun closed 1 week ago

clun commented 2 weeks ago

My proposal is we have this always enabled (with no option to turn it off), simply to the lack of downsides for having it disabled.

~ export class InsertManyError extends CumulativeDataAPIError {
~   declare public readonly partialResult: InsertManyResult<SomeDoc>;
+   declare public readonly documentResponses: InsertManyDocumentResponse[];
~ }

+ interface InsertManyDocumentResponse {
+  _id: SomeId,
+  status: 'OK' | 'ERROR' | 'SKIPPED',
+  error?: DataAPIErrorDescriptor,
+ }

Everything would remain completely backwards compatible—we'd just need to do a tiny bit of work on our end to repackage the response into the "legacy" response format. The main addition would just be the documentResponses field on the InsertManyError which would, of course, contain the document responses, almost exactly as returned from the Data API (we just resolve the errorsIdx field for them)