我希望獲得具有最高數量的UpVotes的最熱門帖子。當多個OrderByChild具有相同的值時,如何在Firebase中進行下一個和上一個操作
this.nextPostObservableList= this.af.database.list('/listOfPost',{
query :{
orderByChild : 'postUpvote',
limitToLast : 2,
endAt : this.currentPost.postUpvote
}
});
在這種情況下,如果我orderByChild與postUpvote,我能夠導航此起彼伏。但是,如果多個帖子具有相同的upVote計數,那麼我無法導航(根據上述代碼片段,大於2)。在以下場景中超越post2。請提出解決方案。
{
"post1" : {
"postUpvote" : 10,
"postname" : "sample 1"
},
"post2" : {
"postUpvote" : 10,
"postname" : "Sample 2"
},
"post3" : {
"postUpvote" : 20,
"postname" : "sample3"
},
"post4" : {
"postUpvote" : 10,
"postname" : "sample4"
}
}
嗯.. 。Firebase SDK有一個'endAt',用於此目的需要一個額外的參數(項目的關鍵點)。我不確定這是否包含在AngularFire2中。 –
嗨弗蘭克根據文檔關鍵參數endAt是唯一有效如果OrderBy是使用優先級完成。 :(。[鏈接](https://firebase.google.com/docs/reference/js/firebase.database.Query) –
我很確定我已經測試了使用orderByChild()的關鍵參數。你能試試吧? –