Firebase QueryOrderedByChild以及EqualToValue和StartingAtValue组合 [英] Firebase QueryOrderedByChild along with EqualToValue and StartingAtValue Combination
问题描述
我试图通过一个等于某个特定值的子查询Firebase,但是在特定的发布键上启动快照。
数据结构:
projectName
-posts
-postKey1
-storeId:1
-postKey2
-storeId:2
-postKey3
-storeId:3
-postKey4
-storeId:2
-postKey5
-storeId:3
-postKey6
-storeId:2
示例: 我试图用<$ c $ queryOrderedByChild(storeId) c> queryEqualToValue(2)但是我希望快照在按照顺序返回的时候从postKey4开始。 我当前的查询: 打印: postKey4 postKey6 我必须承认这是我第一次使用第二个参数到 你不能使用 I am trying to query Firebase by a Child that is equal to a certain value BUT start the snapshot at a specific post key. Data Structure: Example: I am trying to My Current Query: I know that you can't call You can pass a second argument into This prints: postKey4 postKey6 I must admit this is the first time I use the second argument to The reason you can't use 这篇关于Firebase QueryOrderedByChild以及EqualToValue和StartingAtValue组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b
ref.queryOrderedByChild(storeId)。queryEqualToValue(\我知道你可以通过这个方法来创建一个新的表单。在
之前被调用,但我需要 queryStartingAtValue
, queryEndingAtValue
或<$之后调用 queryEqualToValue:
c $ c> queryEqualToValue queryEqualToValue
来获得我的storeId。您可以将第二个参数传递给 queryStartingAtValue $ c $> c $> b
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b $ 2,childKey:postKey4)
.queryEndingAtValue(2)
.observeEventType(.Value,withBlock:{快照在
中用于snapshot.children中的childSnapshot {
print(childSnapshot .key !!
}
})
queryStartingAtValue
,所以我可能还不完全理解它。
queryEqualToValue
的原因是它只会返回一个单一的键,这不是你想要的。 projectName
-posts
-postKey1
-storeId: 1
-postKey2
-storeId: 2
-postKey3
-storeId:3
-postKey4
-storeId:2
-postKey5
-storeId:3
-postKey6
-storeId:2
queryOrderedByChild("storeId")
with queryEqualToValue("2")
BUT I would like the snapshot to start at "postKey4" when it is returned in its order.ref.queryOrderedByChild("storeId").queryEqualToValue("\(myId)").observeEventType(.Value, withBlock: {snapshot in
queryEqualToValue:
after queryStartingAtValue
, queryEndingAtValue
or queryEqualToValue
after previously called but I need that queryEqualToValue
to get my storeId. Any help is greatly appreciated!queryStartingAtValue
that specifies the key at which to start.ref.queryOrderedByChild("storeId")
.queryStartingAtValue(2, childKey: "postKey4")
.queryEndingAtValue(2)
.observeEventType(.Value, withBlock: {snapshot in
for childSnapshot in snapshot.children {
print(childSnapshot.key!!
}
})
queryStartingAtValue
, so I might not understand it completely yet. queryEqualToValue
is that that will only return a single key, which is not what you want.