Windows Azure SDK for Node.js Updating Batch Table Storage

Hello, I am using the Windows Azure SDK for node, but I cannot figure out how to perform a batch update using this library:

https://github.com/WindowsAzure/azure-sdk-for-node/blob/master/lib/services/table/batchserviceclient.js

since I could not find examples of how to do this. Has anyone used the isInBatch property of tableService.js to batch update, delete, and insert?

Any help or advice would be appreciated.

Greetings

+4
source share
1 answer

In the Windows Azure SDK for node github repo , see an example blog in /examples/blog . In particular, blog.js. Here you will see an example of code starting at line 91, where a series of blog posts is written to the same section in an object group transaction:

  provider.tableClient.beginBatch(); var now = new Date().toString(); provider.tableClient.insertEntity(tableName, { PartitionKey: partition, RowKey: uuid(), title: 'Post one', body: 'Body one', created_at: now }); provider.tableClient.insertEntity(tableName, { PartitionKey: partition, RowKey: uuid(), title: 'Post two', body: 'Body two', created_at: now }); provider.tableClient.insertEntity(tableName, { PartitionKey: partition, RowKey: uuid(), title: 'Post three', body: 'Body three', created_at: now }); provider.tableClient.insertEntity(tableName, { PartitionKey: partition, RowKey: uuid(), title: 'Post four', body: 'Body four', created_at: now }); provider.tableClient.commitBatch(function () { console.log('Done'); 

Pay attention to the section item. This is the only way to write multiple objects in a single transaction: they must be in the same section.

EDIT . As @Igorek rightly notes, a single transaction of a group of objects is limited to 100 objects. In addition, the entire transaction payload cannot exceed 4 MB. See this MSDN article for full details on object group transactions.

+4
source

Source: https://habr.com/ru/post/1415045/


All Articles