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.
source share