0

我正在使用 Azure Node.js SDK,但无法让此查询正常工作:

var ts1 = azure.createTableService(config.storageAccount, config.storageAccessKey, config.tableHost);
var query = azure.TableQuery
    .select()
    .from('users')
    .where('PartitionKey eq ?', '0')
    .and('FriendsSeeVideo eq ?', 'true')
    .and('Status eq ?', 'Active');

var firstTimeThrough = true;
for (f in friends){
    if (firstTimeThrough){
        query.and('UserID eq ?', friends[f].id);
        firstTimeThrough = false;
    }
    else query.or('UserID eq ?', friends[f].id);
}

当我将查询写入屏幕时,我得到一个如下所示的 Azure 表查询:

query = {"_fields":[],"_from":"users","_where":["PartitionKey eq '0'"," and FriendsSeeVideo eq 'true'"," and Status eq 'Active'"," and UserID eq '763424639'"," or UserID eq '1385552681'"," or UserID eq '100001386550915'"," or UserID eq '100001869159941'"],"_top":null,"_partitionKey":null,"_nextPartitionKey":null,"_rowKey":null,"_nextRowKey":null}

但它没有返回我期望的结果。有 1 个用户满足表存储条件,结果应该返回用户 ID 为 763424639 的用户,但不是吗?

基本上,我传入一个朋友集并询问表存储这些人是否存在于用户表中,如果他们启用了 FriendsSeeVideo 设置,则返回他们。

谁能看到我做错了什么?

4

2 回答 2

0

I was calling the field [FriendsSeeVideo] by the wrong name it should have been [FriendsSeeVideoView].

I think I'll leave this question on SO because my example code can help somebody wondering how to compare and retrieve sets from table storage.

于 2012-11-03T04:42:22.570 回答
0

只是一个猜测,但也许您想使用布尔值 true 而不是字符串“true”?很难从中看出哪里出了问题……也许您可以向我们展示您希望返回的实际实体。

于 2012-11-02T07:32:52.317 回答