我正在使用azure函数中的azure-storage模块从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
}

结果对象看起来很奇怪,因为每个列的值都是用一个“u”键放入它自己的对象中的,所以json看起来如下:
{
    "PartitionKey": {
        "$": "Edm.String",
        "_": "Keyname"
    },
    "RowKey": {
        "$": "Edm.String",
        "_": "Keyname"
    },
    "Title": {
        "_": "The Item Title"
    }
}

而不是我所期望的:
{
    "PartitionKey": "Keyname",
    "RowKey": "Keyname",
    "Title": "The Item Title"
}

表在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);
    }
}

10-08 06:11
查看更多