这是调用insertEntity()
时发生异常的更多帮助。在Nodejs的Azure表存储中插入实体时添加PartitionKey样本
我在Azure上使用Nodejs并在摩纳哥进行编辑,并且我已经安装了NPM-最新版本的Azure存储。
我遇到的唯一的例外是:(底部完整的堆栈跟踪)
Unaught exception: Error: Parameter entityDescriptor.PartitionKey for function entityOperation should be an object at ArgumentValidator._.extend.object
我基本上把我的对象保存,并创建两个新的属性:PartitionKey
和RowKey
。我给他们字符串值。我是following the examples。我没有使用entityGenerator,因为这里的示例没有这样做,而Azure Node开发人员门户上的示例却这样做。如果需要,我不介意在存储特定的属性上使用entityGenerator,但节点azure github repo中的示例似乎表明您可以使用简单的字符串。诚实地说,entityGenerator看起来有点丑陋和麻烦,因为当你把它带回来时,你必须在实体上编写额外的代码。
如何调整我的代码以解决此问题并呼叫insertEntity()
成功?
exports.saveTally = function(tally, callback) {
var tableSvc = getAzureTableService();
tableSvc.createTableIfNotExists("tally", function(error, result, response) {
if (!error) {
tally.PartitionKey="tally";
tally.RowKey = tally.id;
tableSvc.insertEntity("tally", tally, function(error, result, response) {
if (error) {
console.log("*Error saving tally " + error.toString());
}
else {
callback(tally.id);
}
});
}
});}
简直令人难以置信!没有任何向后兼容性的这种变化,这是Microsoft的方式;-)所有的文档仍然指的是旧的(http://azure.microsoft.com/fr-fr/documentation/articles/storage-nodejs-how -to-use-table-storage/...),这让我记得Silverlight ... –
你可以在这里了解更多关于新SDK的信息:http://blogs.msdn.com/b/windowsazurestorage/archive/2014/ 06/26/microsoft-azure-storage-client-module-for-node-js-v-0-2-0.aspx –
@ThomasDecaux不幸的是,我们还没有更新非英文的Azure存储节点文档。但是,等效的英文文档[此处](http://azure.microsoft.com/zh-cn/documentation/articles/storage-nodejs-how-to-use-table-storage/)完全是最新的。 –