Tho*_*mas 2 azure-storage node.js azure-table-storage azure-functions
我正在使用azure-storageAzure函数中的模块从Azure存储表读取数据。
获取这样的行
var tableSvc = azure.createTableService();
var query = new azure.TableQuery().top(1000);
tableSvc.queryEntities('tablename', query, null, function(error, result, response) {
// work with result.entries
}
Run Code Online (Sandbox Code Playgroud)
由于使用“ _”键将每个列值放入其自己的对象中,因此生成的Object看起来很奇怪,因此JSON如下所示:
{
"PartitionKey": {
"$": "Edm.String",
"_": "Keyname"
},
"RowKey": {
"$": "Edm.String",
"_": "Keyname"
},
"Title": {
"_": "The Item Title"
}
}
Run Code Online (Sandbox Code Playgroud)
而不是我所期望的:
{
"PartitionKey": "Keyname",
"RowKey": "Keyname",
"Title": "The Item Title"
}
Run Code Online (Sandbox Code Playgroud)
该表在Azure存储资源管理器中看起来很正常。这正常吗?还是可以以某种方式影响查询的输出?
您可以将有效负载格式指定为application/json;odata=nometadata,然后通过获取结果对象response.body.value。
var options = { payloadFormat: "application/json;odata=nometadata" };
tableSvc.queryEntities('tablename', query, null, options, function(error, result, response) {
if(!error) {
console.log(response.body.value);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
613 次 |
| 最近记录: |