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

RDoc-2699 [Node.js] Document extensions > Attachments > Bulk insert [Replace C# samples] #1801

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

Danielle9897
Copy link
Member

Related issue:
https://issues.hibernatingrhinos.com/issue/RDoc-2699/Node.js-Document-extensions-Attachments-Bulk-insert-Replace-C-samples


Node.js: @ml054

  • Node.js files to review:
Documentation/5.4/Raven.Documentation.Pages/document-extensions/attachments/bulk-insert.js.markdown
Documentation/5.4/Samples/nodejs/documentExtensions/attachments/bulkInsert.js

C#:

  • Files were copied over to v5.4 and organized

@Danielle9897 Danielle9897 requested a review from ml054 March 19, 2024 14:14
@Danielle9897 Danielle9897 marked this pull request as draft March 20, 2024 12:15
@Danielle9897 Danielle9897 marked this pull request as ready for review March 20, 2024 12:49
await attachmentsBulkInsert.store("attachmentName", byteArray);
}
} finally {
// Persist the data - call finish
Copy link
Member

Choose a reason for hiding this comment

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

Im not sure if saying Persist is equivalent of calling finish, as it might suggest it is persistent in single shot.

It is rather saying to the server: I've finished, flush data, save it and return once completed.

Copy link
Member Author

@Danielle9897 Danielle9897 Mar 21, 2024

Choose a reason for hiding this comment

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

I updated comments - hope it's better like this:
Added: // The data stored in bulkInsert will be streamed to the server in batches
Modified: // Call finish to send all remaining data to the server

try {
            for (let i = 0; i < users.length; i++) {

                // Call `attachmentsFor`, pass the document ID for which to attach the file
                const attachmentsBulkInsert = bulkInsert.attachmentsFor(users[i].id);
                
                // Call 'store' to attach the byte array to the bulkInsert instance
                // The data stored in bulkInsert will be streamed to the server in batches 
                await attachmentsBulkInsert.store("attachmentName", byteArray);
            }
        } finally {
            // Call finish to send all remaining data to the server
            await bulkInsert.finish();
        }

I will update the Node.js README as well..
See pr: ravendb/ravendb-nodejs-client#416

@Danielle9897 Danielle9897 requested a review from ml054 March 21, 2024 08:28
@ppekrol ppekrol merged commit b325b08 into ravendb:master Mar 21, 2024
1 of 2 checks passed
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.

3 participants