在 Windows Azure SDK for Node github 存储库中,查看下面的博客示例/examples/blog
。具体来说,是 blog.js。在这里,您将看到从第 91 行左右开始的示例代码,其中一系列博客文章在实体组事务中写入同一分区:
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');
Run Code Online (Sandbox Code Playgroud)
请注意分区的要点。这是在单个事务中写入多个实体的唯一方法:它们必须位于同一分区中。
编辑- 正如 @Igorek 正确指出的那样,单个实体组交易仅限于 100 个实体。此外,交易的整个有效负载不得超过 4MB。有关实体组事务的所有详细信息,请参阅此 MSDN 文章。
归档时间: |
|
查看次数: |
993 次 |
最近记录: |