Azure 存储 Table 查询 - 结果与响应

Azure Storage Table Query - result vs response

我正在使用 node.js 作为我的服务器,并且在我的存储 table 所在的 Azure 上有一个帐户。我正在使用以下命令检索特定分区的所有记录:

var query= new azure.TableQuery().where('PartitionKey eq ?',username);
tableSvc.queryEntities(localTableName,query, null, function(error, result, response) {

}

当此调用返回时,我想访问 table 其余字段的值。但是当我使用 result.entries 这样做时,它看起来有点奇怪。或者我想我可以通过 response.body.value.userID.

访问结果

下面是 "result.entries" 与 "response" 对象的结构:

    result.entries :
    [ { PartitionKey: { '$': 'Edm.String', _: '048tfbne' },
        RowKey: { '$': 'Edm.String', _: '145610564488450166' },
        Timestamp: 
               { '$': 'Edm.DateTime',
                   _: Mon Feb 22 2016 01:47:26 GMT+0000 (UTC) },
        username: { _: '048tfbne' },
        userID: { _: '145610564488450166' },
        deleteAfter: { _: 'not set yet' },
        '.metadata': { etag: 'W/"datetime\'2016-02-22T01%3A47%3A26.4394133Z\'"' } } ]

    response : 
    { isSuccessful: true,
        statusCode: 200,
              body: 
                { 'odata.metadata': 'https://photoshareuserdata.table.core.windows.net/$metadata#userIdentifier',
                value: 
                    [ { 'odata.etag': 'W/"datetime\'2016-02-22T01%3A47%3A26.4394133Z\'"',
                        PartitionKey: '048tfbne',
                        RowKey: '145610564488450166',
                        Timestamp: '2016-02-22T01:47:26.4394133Z',
                        username: '048tfbne',
                        userID: '145610564488450166',
                        deleteAfter: 'not set yet' } ] },

我认为 results.entries 是访问记录的更好方法,但嵌套对象和此处的 Edm.String 让我感到有点奇怪。

哪种访问记录的方法更好?

Table Node Sample 显示如何访问 table 中的实体作为查询结果。请参阅方法 "runPageQuery"。

其实,根据官方Section: Query a set of entities,有一段是这样的:

If successful, result.entries will contain an array of entities that match the query. If the query was unable to return all entities, result.continuationToken will be non-null and can be used as the third parameter of queryEntities to retrieve more results.

我们还可以参考 GitHub 上的 Azure-storage-for-node 存储库中的 sample。这已经告诉了我们答案。