Ios 返回奇怪结果的Firebase查询

Ios 返回奇怪结果的Firebase查询,ios,objective-c,firebase,Ios,Objective C,Firebase,我在我的应用程序中使用Firebase,我得到了一个路径,其中包含“linked_timestamp”值为kFirebaseServerValueTimestamp的子节点。我使用此代码仅返回不超过24小时的项目: Firebase *usersRef = [[Firebase alloc] initWithUrl:@"https://<MY-APP>.firebaseio.com/users"]; Firebase *itemsRef = [usersRef childByAppe

我在我的应用程序中使用Firebase,我得到了一个路径,其中包含“linked_timestamp”值为
kFirebaseServerValueTimestamp
的子节点。我使用此代码仅返回不超过24小时的项目:

Firebase *usersRef = [[Firebase alloc] initWithUrl:@"https://<MY-APP>.firebaseio.com/users"];
Firebase *itemsRef = [usersRef childByAppendingPath:[NSString stringWithFormat:@"/%@/items/", userId]];

double currentTimeSince1970 = (double)[[NSDate date] timeIntervalSince1970];
double epochTime = currentTimeSince1970 * 1000;
double startingAtTimestamp = epochTime - (24 * 3600000);
NSNumber *startingAtTimestampNumber = [[NSNumber alloc] initWithDouble:startingAtTimestamp];

FQuery *itemsQuery = [[itemsRef queryOrderedByChild:@"linked_timestamp"] queryStartingAtValue:startingAtTimestampNumber];
[itemsQuery observeSingleEventOfType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
    // Downloaded
}];

答案是54354存储为字符串而不是数字

我犯过好几次这样的错误


如果进入Firebase仪表板,您可以单击54354字段,它将在数字“54354”附近显示paren。删除这些,您的代码将正常工作。

您能将实际的Firebase数据结构复制/粘贴到您的问题中吗?您可以使用仪表板右上角的“导出”按钮将其导出为平面文件。@Jay现在粘贴了它,它在某种程度上从原始结构中剥离出来,以避免破坏应用程序的构思或显示大量行,但它显示了问题查询中使用的结构和数据。好。它在按你的要求做。如果在Firebase中有54354作为值,那么Firebase查询将返回该值。在我看来,写这些值有点问题。@Jay-hmm,不太清楚你在这里的意思。
FQuery
是否会限制返回到具有子节点值(链接的时间戳)>当前unix历元时间(以毫秒为单位)的父节点的结果有10^12那么大。我道歉。我想你的意思是数字太少了,即54354没有1457119545959那么多数字。看到我的答案了吗
{
"items" : {
"-KBOcj7jlWh4wg8WWhyc" : {
    // information
    },
"-KBOcxL4f2-Az4meOLsW" : {
    // information
    }
},
"users" : {
"1117555594922215" : {
  "first_name" : "First name",
  "last_name" : "Last name",
  "items" : {
    "-KBOcj7jlWh4wg8WWhyc" : {
      "linked_timestamp" : "54354"
    },
    "-KBOcxL4f2-Az4meOLsW" : {
      "linked_timestamp" : 1457119545959
    }
  },
  "register_date" : "04-03-2016 18:02"
        }
    }
}